- Home /
Attaching an object to an ongoing animation
My character is a prefab, when i equip the character boots, i cut its feet and give the boots the same transform.parent, rotation and position. But the boots don't act like the feet. The animation is still running for the rest of the body but the boots won't move
I cannot set the boots animation because its a read-only property
what am I missing?
this is what I'm doing in C#
// find the feet
GameObject playerFeet = GameObject.FindWithTag("feet");
// activate the item
equipItem.setActive(true);
// replacing the feet by the item
equipItem.transform.position = playerFeet.transform.position;
equipItem.transform.rotation = playerFeet.transform.rotation;
equipItem.transform.parent = playerFeet.transform.parent;
// makes the feet vanish
playerFeet.SetActive(false);
==update==
I work with feet, not left foot and right foot
=============
thanks
well, your character can't have a 'feet' transform. it must have left foot and right foot... right?
For static things (like plate armor, sandals, stuff that doesn't need to bend within its own mesh), you just use
leftBoot.transform.parent = leftFoot
If the boot needs to animate along with the foot, someone else will chime in with that answer. I can never remember quite how to get that working.
Answer by Jazzer008 · Apr 20, 2013 at 03:01 PM
So, if your default feet are animating with the player, then those are the objects with the animation data.
Personally I would make the feet's renderer inActive, instead of setting the game object to inActive. Then parent the new boots to the feet. That way, the old feet will still move with the animation, but will not render, and your new boots will follow the transform of the old feet.
equipItem.transform.parent = playerFeet.transform;
// makes the feet vanish
playerFeet.renderer.enabled = false;
my problem is that im new in unity. Your solution didn't work.Also already had tried to keep the feet enabled before. The problem is that Im not an animator and dont quite understand how all components fit together. heres a screenshot of the hierarchy, it might help you helping me to understand what im doing wrong.
Ok, I was fairly sure that that would work. :D
I'm just going to test it in my own Unity and try and find the issue. Back in 5 $$anonymous$$utes. :P
Edit: Ok, I just checked and I parented a new object to a moving part and the new object moved with the part.
Why don't you try adding the new boots as a child, to your female_feet object, in the editor. Then play the game and see if they follow the transform of the feet.
forgot to say changing the animator culling mode from based on rendered to always animate made the boots animate... but then the body stopped :\
So here's my result
You can see the attached sphere is moving with the animated part that it is parented to.
I have a feeling that my animation is quite different from yours though. I have no bones and the animation is stored in the root.
Are you using bones? And could you take a picture of your 'rig' page, showing the import settings of the animation in the inspector.
yes its different, that ball is only following the other component. So all you are doing is using transform coordinates. This is a bit different. The boots are following the feet... they are just not using the same animation. we're using a mecanism compatible rig and an animation from a unity mecanism demo package for testing