How to make attachable/detachable parts in a model (Using BindToActor)

The BindToActor function (CTVActor class) is one of the easiest and fastest methods to achieve attachable and/or detachable parts for an Actor class.

I’ll go straight forward for a very explanatory example. How to attach a sword and a head to an actor!

Our main actor doesn’t have a head nor a weapon attached to it (or him? never known if I should treat Actors as persons or objects, but that’s another question!). We’ll fix that :p

First, you need to add a bone to the head and the sword files named Head and RightHand (for eg). Save and export as static TVA. Only needed bones have to be added. For our example, (Head and Sword) each model needs only to have one bone.

The Warrior MUST have bones called Head and RightHand (exactly the same as the Sword and the head bones).

Then in your application you need to declare and load all actors (Body, Head and Sword).

Public Body = Scene.CreateActor("Body")
Public Head = Scene.CreateActor("Head")
Public Sword = Scene.CreateActor("Sword")
'Specify all what you need for your actors (Materials, Textures....etc) as usual.

Finally, just use the “magic trick” (Binding Head and Sword to the Actor, in that order).


And it’s done! The Head and Sword will be automatically rotated and moved with the main actor.

Note: TV will “merge” bones with the same name in the two actors (Body and Sword). So the position of the RightHand bone in the Sword model is important. If you find that the Sword doesnt fit well with the actor, try to change the position of the bone in the Sword model (DON’T TOUCH THE BODY MODEL)

Note 2: Don’t forget to render all actors (Body, Head and Sword)

The Head and the Sword are good examples for understanding, then you can apply this method for anything you want (Shield, armor, hat, helmet, clothes, armors, hands, legs, etc...)

As you can see in that picture, we can combine different models to have non identical actors in-game (in this pic, Shields, Heads, Helmets and Weapons are randomized for each body.)

tutorialsarticlesandexamples/bindtoactor.txt · Last modified: 2019/02/10 09:38 by