- Home /
animating objects, end position changes
newb question here:
So I have a box playing an animation when I press the space bar..My problem right now is that every time the animation ends in a different position..Here's what I did:
so I have a box placed inside an empty gameObject. I set up a script for the gameObject to move left and right with the A and D keys. Then I animated the box inside the gameObject to "jump" every time I press the spacebar:
function Update () {
if (Input.GetButtonDown("Jump")){
animation.Play("jump");
}
}
the end position of my animation is different every time.. sometimes lower, sometimes way higher.. Anyone can point out what i'm doing wrong :)
Answer by Paulius-Liekis · Oct 27, 2010 at 08:52 AM
There is a bug in Unity 3.0 which causes animations not to sample last frame. Let say it samples animations at 0.95 (normalized time) and at next frame it will increment time to 1.05, so it won't sample the animation.
People use various solutions to that:
- Use ClampForever mode (but then animation doesn't blend out)
- Control normalized time yourself
- Sample last frame of animation yourself
- Just ignore the issue (that is what I prefer - do not rely on some particular frame to be sampled, but of course it depends on game mechanics)
BTW.: I fixed this after Unity 3.0 has been release, but I don't know when the fix will be available to the public (should be Unity 3.2).*-
Your answer
![](https://koobas.hobune.stream/wayback/20220613081000im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Character won't play animation 8 Answers
play animation with script 4 Answers
what is the jump axis for if (Input.GetAxis(" ? ") 2 Answers