ok so i have played with unity and i understand how it works and all that other good stuff. However what i cant grasp right now is that im starting to make animations and i would like to know,(say im making a shooter) do you animate the character while holding the gun or animate him without the gun and put it in later? I just dont really understand how it works right now so if anyone can give me just a little clearing up on it that would be helpful:smile:
no, what im talking about is when you import your character into unity (for a shooter) does the character have to be animated with or without holding the weapon
You attach the gun later. What most people do is have a “Weapon_Bone” attached to the hand of the character.
Animate him in your modeling app with the weapon as a child of the “Weapon_Bone” and then when you are ready to import into unity, take the gun out of the character model. Then import the gun model in a second file and attach it to “Weapon_Bone” via scripting.
Of course It wont work,
1- you cannot affect that object’s transform directly,
2 - GameObject is a class, you need an instance of that class like so: gameObjectIf your class inherits from Monobehaviour, by default you have access to its own Transform instance: transform.
3 - Here is what you need to do in order to make your weapon child of your hand bone (to follow the hand bone):
//No need to run this each frame, only once
void Start(){[INDENT] weaponTransform.parent = handTransform.transform;
[/INDENT]}