Jump to content

[LE3] Attach weapons to entity : How to ?


YouGroove
 Share

Recommended Posts

I have some character, and i would want ot attach some different weapons in two hands by code.

Caus it will be dynamic, you can equip and change weapons any time.

 

Does someone already tried that ?

I mean good positionning and orientation ?

 

I 've done the model in Blender, perhaps it is some way to export weapons only but well placed in the scene? i mean export weapons without animations, only static models ?

Stop toying and make games

Link to comment
Share on other sites

without having done this myself i would say you could have pivots on your character where the weapons should be positioned and the weapons should have some animations that are played the same time as the character animation.

Link to comment
Share on other sites

Nope.

Weapons are not animated to character specific animations.

 

Search on any 3D engine forums or features : Weapons and stuff are attached to bones , so you can attach anything you made and that don't have animations.

That's the way it's done on any 3D engine, and it's the best caus independant on character or it's animations.

 

The other solutioon would be impossible.

If i had 100 weapons, i would have 100 times the same models and animations exported ? i can't imagine the amount of work and space disk for the game laugh.png

 

*************

 

So yes, before going shadows, and eye candy stuff, LE3 engine should really provide essential functions to be able to make real games.

Stop toying and make games

Link to comment
Share on other sites

beo6 :

Indeed if you just double click on barbarian you will see :

IT's ONE MODEL ONLY : BARBARIAN + WEAPON.

So indeed it's well placed and it's ONE WHOLE ANiMATED MODEL.

 

There is not attaching function or whatever.

 

I would like :

"Eternal Light" game with a barbarian that could change weapons in game. really.

 

LE3 instead of delivering some eye candy version, should make the actual lot more stable and finalized :

1) CORRECT SEVERE BUGS

2) TAKE ACCOUNT OF VERY NEEDED REQUESTS (camera gizmo, light gizmos , BSP requests etc ...)

3) ADD ESSENTIAL FUNCTIONS (bones and attaching functions for example)

Stop toying and make games

Link to comment
Share on other sites

Hi YouGroove,

 

I am in the process of migrating my inventory code and yes it appears to work so far. The way I line it up is have a dummy node linked to the players hand and a dummy node on the weapon which is used to set the position and transform. That way I can visually see how things line up.

 

 

itemMountNode->SetParent(mountNode);

 

itemMountNode->SetMatrix(mountNode->GetMatrix());

 

The weapons are sorted in a vector and iterated upon. As I'm switching weapons they are shown/hidden as necessary and always have a pointer to the current weapon.

 

I'm writing this quickly before work, hope this helps.

trindieprod.png?dl=0spacer.png?dl=0steam-icon.png?dl=0twitter-icon.png?dl=0spacer.png?dl=0
Link to comment
Share on other sites

Thanks.

I tried but it failed.

 

In Blender i put the character in edit mode (not pose) , than put the weapon on the good place in the hand, before exporting the weapon only. By code the weapon is loaded , than placed using Matrix, but it is in some strange place and not rotated well, but at least it follow the player.

 

I'll go with fixed weapons shape and only texture variations i think.

Or keep that part for later when someone will post some Lua solution (im' not a super programmer sad.png )

Stop toying and make games

Link to comment
Share on other sites

I'll try thanks.

Matrix functions seems to work , but not perfect. like i said , perhaps it's my weapon not correctly exported ?

I put it at origin before export, perhaps rotation and other wan't good.

It can be my models the problem not the code.

But if anyone could have some Goblin with some simple weapon made of cubes working and the code, i will be happy to take it laugh.png

Stop toying and make games

Link to comment
Share on other sites

Thanks for the help.

 

Here is another way that seems to work :

(the weapon is loaded in App.lua for the test)

 

 

-- Get the bone by name of the hand of the character to attach the weapon
local child = self.entity:FindChild("Bone.009")
--Get matrix of the bone
[size=4] mat = child:GetMatrix();[/size]
[size=4]--Apply matrix to the weapon[/size]
App.weapon:SetMatrix(mat)

 

I'll have to figure out how to export weapon to kep it well placed in the character hand.

Or the other way is to give some offsets values to position the weapon after Matrix placement.

Stop toying and make games

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...