Home Game Development Unity keyframe animations not clean?

Unity keyframe animations not clean?

0
Unity keyframe animations not clean?

[ad_1]

I am new to Unity generally, and notably to animations, however what I am attempting to do needs to be pretty primary so I am most likely doing one thing easy fallacious.

I’ve damaged this down right into a quite simple demo case: I must spin a dice easily.

This is what I’ve achieved:

  • Created a TestCube.
  • Utilizing the Timeline window, created a Director element with a Playable.
  • Added an Animation Monitor to the timeline linked to TestCube (which robotically added the Animator element to the dice).

I then recorded a quite simple animation with two keyframes, the place I rotate TestCube 180 levels.

Animation curve

The end result appears okay at first look, however in actuality it’s truly fairly jittery and uneven. I created a easy script to log how a lot the dice rotates every body. In my actual utility, I am primarily working in FixedUpdate, however I am concerned with each, so I logged each.

utilizing UnityEngine;

public class Check : MonoBehaviour
{
    personal Quaternion previousUpdateRotation;
    personal Quaternion previousFixedUpdateRotation;

    personal void Awake()
    {
        previousUpdateRotation = remodel.rotation;
        previousFixedUpdateRotation = remodel.rotation;
    }

    personal void Replace()
    {
        Debug.Log($"Replace|{Quaternion.Angle(previousUpdateRotation, remodel.rotation)}");
        previousUpdateRotation = remodel.rotation;
    }

    personal void FixedUpdate()
    {
        Debug.Log($"FixedUpdate|{Quaternion.Angle(previousFixedUpdateRotation, remodel.rotation)}");
        previousFixedUpdateRotation = remodel.rotation;
    }
}

I then graphed the output:

Angle Delta - Update - Normal
Angle Delta - FixedUpdate - Normal

As you possibly can see, the rotation of the dice could be very a lot not clean. My first thought approach possibly the Animator.UpdateMode parameter might assist me. I set it to Animate Physics and ran the take a look at once more, hoping to get a greater end result on FixedUpdate. However I received related outcomes.

Angle Delta - Update - Animate Physics
Angle Delta - FixedUpdate - Animate Physics

Can anybody inform me what I am doing fallacious? How can I get a clean response to match the smoothness of the animation curve?

[ad_2]

LEAVE A REPLY

Please enter your comment!
Please enter your name here