- Home /
Transform.Rotate keeps snapping back to original position after it has finished
Dear everyone,
I am making a 3D character in unity that has both an animator component and is able to move its wrist using the Rotate function from the Transform class. I am using this function because I need a way for the palm to for instance always point up or down no matter where the rest of the body is. The Rotate function allows me to set the orientation relative to the world vector which fixes this issue. The problem however is that when the wrist is done rotating, it snaps back to its original position. I could just keep calling the rotate function but this causes a decrease in performance and other issues in my program. I have identified the problem to lie somewhere in the animator. If I disable the animator, the animation spaces out and stops working completely for some reason. Any help with this issue is highly appreciated,
Thank you in advance, Matthijs
void LateUpdate()
{
// To start animation, set t to 0.01 and set the targetPalmor
if (t > 0){
// calculate 1 step in the animation
float anglePalmor = Mathf.Lerp(0, targetPalmor , t);
t += 0.5f * Time.deltaTime;
forearm.Rotate(0, 0, anglePalmor, Space.World);
// animation is done.
if(t > 1)
t = 0;
}
}
Your answer
![](https://koobas.hobune.stream/wayback/20220613033702im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Animator plays after movement 0 Answers
Noob questions about animator 0 Answers
Animation play 3D problem 0 Answers
2D Animation does not start 1 Answer
Using animation curves for fall and roll-over in and endless runner 3d 0 Answers