- Home /
Movement and animation
We have a path-finding/path-following script that navigates a character around fixed objects to reach its destination. We tested it out, and it works. So far, so good.
But as soon as we set it to start the character's walk animation (an animation of him walking in place . . . the path-following script takes care of the actual translation), the character's position keeps getting set back to his starting position every 10 or so frames (leading to a stuttering kind of motion). If I turn off the animation, the character translates as expected once again. It's as if the animation is somehow resetting the character's position.
Does this ring a bell to anyone? It sounds similar to Hunter_jonny's 2D problem here: http://answers.unity3d.com/questions/10789/animation-freezes-my-movement
But it doesn't look like he got an answer. (We already tried the empty game object suggestion, but that didn't make a difference, unfortunately)
Thanks, in advance for your help!
Are you doing the http://unity3d.com/support/documentation/ScriptReference/Animation.CrossFade.html cross fade? If not, try that.
Can we see the scripts where the problem seems to be located?
Try looking at the character's Transform in the Inspector as you run. Is the position really being snapped?
Just switched to cross fade, but it behaves the same.
I should mention that the behavior was actually different when we added the empty game object as a parent - without the parent, the character exhibits the stuttering motion - with the parent, he moves, but from time to time it pops to a new location (sometimes clear across the level). This may happen every time the character rotates. We're looking into that now.
We also noticed that the character already has a position before we drag it into the scene. We're investigating to see why and see if that is affecting us at all.
Owen, when the character stutters (no game object above it), the position does indeed snap back. With a game object the position seems to update correctly, though the actual character is popping all over the place in the scene.
Answer by Bunny83 · Mar 29, 2011 at 05:25 PM
I guess your animation animates the pivot point of your character. At least in one frame. You can check the animation in Unity with the animation window. Just open it and select your character (the GO where the Animation component is attached to). Now you can see all animation curves. Make sure that the parent (the topmost transform that you move via script) is not animated. Animations are absolute. That means there is no relative movement in animations so if your pivot have a transform.position curve that would set the character to the animated absolute position.
Your animations should be animated in place. Unity don't support motion delta and since you move your char with your own script i guess you had that already in mind.
Your answer
Follow this Question
Related Questions
Weird jumpy motion of character in Navigation Fundamentals proect 0 Answers
Moving a Character Along a Path in Timeline 0 Answers
scripting for animation 0 Answers
Irregular Spherical Pathfinding 1 Answer