[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 aDirector
element with aPlayable
. - Added an
Animation Monitor
to the timeline linked toTestCube
(which robotically added theAnimator
element to the dice).
I then recorded a quite simple animation with two keyframes, the place I rotate TestCube
180 levels.
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:
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.
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]