This issue is annoying me now… I have two different models, both with humanoid rigging and using humanoid avatars. They use a shared AnimatorController which works great except for one animation - the RunForward animation. For reasons I am unable to fathom, one model will animate perfectly with this anim, and the other goes to hell. The issue seems to lie in the XZ translation, as one model will fly wildly off course, and the other follows the path normally.
See this video for an example:
It’s weird that only this animation is affected. It’s especially weird because they share the same controller, so are using the same animation take. In the animation preview window, I can switch between the two models and they preview plays the same for both. It’s only in the game that things get messed up. I have no idea the cause - they are both moving with the same movement speed, have the same scripts running on them, and identical everything, except for the model used. Yet both models use valid humanoid avatars, and all the other animations in the controller work fine.
I’m at a complete loss as to the cause of this. Has anyone else come across a similar problem or have a guess as to the cause?
Could you submit a bug report with a scene showing your problem. Also reply to this thread with the case number, will be easier for use to track it down.
I’m having the same problem following the mecanim video unity made. I made a blender model like the one shown here
I put the same controller as Kyle Robot, bot control, He starts out vertical Idling but when I move him he falls forward 90 degrees, his
y (green) is up, so it must be something in the bot control script. I also made a game object with y green up and parented him, same
effect.
@Mecanim.Dev
I have tried to make a scene that reproduces the problem, but for some reason the problem won’t repeat itself. I thought it must have been script related, so in my main project I removed all scripts bar the animation scripting which the two models shared, and the problem remained. Unfortunately my main project is too big for me to send, and I can’t find a way to reproduce the bug outside of my project. At this stage I’m thinking it must have been related to the models or animations somehow, but I don’t know for sure.
That said, I did find a solution that worked for me - by setting Animator.applyRootMotion to false, both models behaved the same way when animating.
My only guess as to why the model movement went screwy previously was because it was using a mocap animation that had a large amount of root motion. I tried all the different options for baking/not baking root motion, and no combination of settings solved the issue. The truly weird thing though is that one model would be fine and the other messed up while running the same animation. They both used the same Avatar (and I tried giving them separate Avatars) and both had the most basic of movements via scripting. Very strange indeed. Only turning off root motion in the Animator made the models behave, which is fine for my project because the models are moved by script anyway. Sorry I couldn’t be any more help.
Well if you move the root by script you should effectively turn off root motion on the animator.
One thing you should know is if you are moving the root you should always do it in a function call OnAnimatorMove which will be call by the engine at the right moment, right after the animation evaluation and just before the IK evaluation. This is needed if you want to use IK goal computed from your animation clip.
The pipeline look like this
your MonoBehavior.Update is called to setup all the parameter
Animator evaluate the State machine and evaluate animation clip
OnAnimatorMove is called to move the root
Animator retarget the motion to your avatar and does the foot planting
OnAnimatorIK is called to setup all the IK goal
Animator evaluate IK and write the final result to your character’s skeleton.
@mecanim.admin
Yes, after I froze the xyz rotations he works like Kylerobot, now how do I get the camera to follow my guy and not the robot? I’ve tried
moving Main Camera onto my guy but it still follows Kyle. BTW, this is a big improvement in animation tech!
I don’t know which script you did use to make the camera follow your character, but if it the script from the mecanim sample the camera do follow the GO with the tag player. Just set tag to player for your character and set the other one to none
@Sonny
quote
Just set tag to player for your character and set the other one to none
unquote
I did that, (kylerobot is ‘untagged’, now my guy is centered, but Kylerobot is running alongside, ‘attack of the clones’. I guess I could just delete Kyle.
For anyone who can’t find them they are on a link below the Youtube tutorial video. I found the address in other articles but the link only seems to work from there.
Following the tutorial I have found a problem with the blending of walking and running. Because the walk threshold is zero and the run is 1 when you press up key the input is1 so you bypass walk and go straight to run. Should I remove run from the locomotion blend tree and try to use a boolean with a “fire1” keystroke please?
What kind of input are you using? If it a key from the keyboard those one return a value of 0 or 1. You need to use an analog controller like the Xbox 360 controller which can return value between 0 and 1. This way you can see the whole range of blending between walk and run.