- Home /
Unity general animation, bones root node rotation to parent container!
For three days I have been trying to find a way where the root node of any type of animation could be used to rotate the parent container.
The idea is that the animation’s rotations (root node or controlling node rotations) also rotate the parent container, resulting in the "parent container" always facing in the correct direction of the animation front, no matter what state it ends in.
This has some good advantages and I would really like to find a solution to the problem. See the image at bottom for what I I'm referring to as the "parent container".
I have been focusing on the Y axis as it’s the most important and I have tried many workarounds but all result in the obvious. The container is a parent and in result any applied rotation also affects the child objects.
Now this just maybe very simple to resolve, if so just slap me with it ;)
What you are trying to do is not clear. For me at least.
by "root" node, do you mean "Bip01" node? Because I think root node is the same one you named as parent container.
Which one do you want to rotate and which one not to rotate?
Can you give a specific example about what you want to do.
Answer by scarletshark · Aug 06, 2013 at 07:51 PM
I really can't think of a situation where you would want to do this... You realize that rotating a parent of a bone based on the bone's rotation would result in 2x the rotation of the bone?
It sounds like what you really want is for the animation to drive the character rotation / translation? If so, you need to look into Mecanim. It simplifies the whole process, and uses character animation as the driver for the movement of the character controller. YouTube Tutorial
But if you really wanted to do this (which I assure you will give you unwanted results...)
GameObject spine = GameObject.Find("m002_hi_max2008_01/Bip01 Pelvis/Bip01 Spine");
GameObject moo = GameObject.Find("/m002_hi_max2008_01");
void Update(){
moo.Transform.Rotation.y = spine.Transform.Rotation.y;
}
Can't check this right now, but you might not be able to set y rotation directly.
These are the exact same sentenced I thought when I read the question. $$anonymous$$ecanim is the right way!
Answer by superme2012 · Aug 06, 2013 at 08:55 PM
Yeah I will scrap this idea and use mecanim humanoid. Thanks for the help.
Please don't forget to accept my answer! Always accept the correct answer (the checkmark next to the answer). It helps people get credibility for answering more questions :)
Hi, I didn’t give it a plus 1 as there is a much easier way to do it. The trick is to add a parent container then move the child out, rotate parent and reset child’s parent.
It’s very easy to do and can’t believe I didn’t work it out sooner.
I should have also mentioned that I am using mecanim generic, the problem I was facing was due to animation doing a full rotation but the container still facing in the opposite direction.
Anyway after more problems I decided to start looking at angular rotation and direction using a navagent. I'm going to use an in place sidestep type animation with a blend tree, hope this works ;)
@superme2012 Whatever you are doing is very uncommon, and does not represent what most developers would do in your situation. I believe your problem is that you have your character model inside another game object.... and you're wanting that game object to rotate. Your solution will work, but I wouldn't recommend it unless absolutely necessary.
I was referring to $$anonymous$$ecanim's built-in ability to rotate and translate objects based on animation data. See this video I made for you: $$anonymous$$ecanim Rotation
In that video, I have the "parent node" selected, which is the character model file titled "robot." It is assigned a mecanim animator... Inside the parent node are the bones and mesh. As you can see, the "parent node" rotates perfectly according to the animation data.
What I'm doing is very uncommon, after tweaking some code last night I managed to get the functionality I was looking for. I did it already but didn’t notice due to the scruffy code lolz
That video is very interesting, I cannot alter any aspect of the bones, in doing so has some nasty results.
What you did was in most cases the solution so I give it the thumbs up.