Jump to content

Model Attachment Support?


RomSteady
 Share

Recommended Posts

Is model attachment support in or planned?

 

In several other 3D engines, I can create a skeletal attachment point to a model, then add other models to those attachment points. It's a good way to handle swappable weapons, armor attachments, etc., without having to just export another model with the stuff prebaked in.

 

Three examples of where this would be useful:

 

Quake III: Arena had two sets of animations: one animation for the melee weapon, and one animation for the two-handed weapons. The weapon would just be attached to the attachment point. This way, the same asset could be used across all the models.

 

Bethesda's games (Elder Scrolls, Fallout) have it so that the weapons the enemies have, either in reserve or equipped, appear on the model.

 

In the last game I shipped (SiN Episodes: Emergence), if an enemy was immune to head shots, we'd add a helmet to the enemy model. When the helmet got shot, we'd pop the helmet off so the enemy could get capped in a single headshot.

Link to comment
Share on other sites

You would find the bone that is your attachment bone:

 

local gunAttachmentBone = self.entity:FindChild("gunAttachmentBoneName")

 

Then you would set that as the parent for you weapon:

 

myweapon:SetParent(gunAttachmentBone)

 

Now that gun/gear/whatever will move with that bone during animations

  • Upvote 1
Link to comment
Share on other sites

You can also in the editor without code , drag and drop some weapon to the bone of a model (in scene tab showing hierarchy of bones of a character).

 

Usefull to make some NPC with a gun, another with another type of of weapon without coding, can be used also to make variations of hair of characters or armors etc ...

Stop toying and make games

Link to comment
Share on other sites

Does the model importer remove any bones that don't have vertex weights assigned to them? I added an attachment joint as a child of the right hand, but when I import the model, the bone doesn't exist.

 

Here's a easiest case reproducible example file: crude-cube.zip.

 

I created a cube and added a base joint to it. I assigned all vertex weights to the base joint. I then created a child joint called AttachmentJoint.

 

If I open the .FBX in Visual Studio 2013, I can see the AttachmentJoint is properly a child of BaseJoint, but if I import the .FBX into Leadwerds, I only have BaseJoint.

 

It's a bit difficult to programatically find a bone that doesn't exist, unfortunately.

Link to comment
Share on other sites

Does the model importer remove any bones that don't have vertex weights assigned to them?

 

I tested it and nope, all is fine imported.

 

I suggest you to work with Blender, it exports correctly to good FBX format.

I think your problem is your original model exported not as it should be, not good standard format.

 

If you provide me some Blender file, i can test and do something.

Unfortunately i can't import any of your cube formats in Blender.

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...