Search Unity

  1. Are you interested in providing feedback directly to Unity teams? Sign up to become a member of Unity Pulse, our new product feedback and research community.
    Dismiss Notice

Rotation Animation Jitters

Discussion in 'Animation' started by vinfang, Sep 2, 2013.

  1. vinfang

    vinfang

    Joined:
    Jul 13, 2013
    Posts:
    14
    I'm using the Unity 4.2 and wanted to do a simple test making our logo on a sphere that rotates. I created a sphere, and then an animation component that the sphere uses to rotate a full 360 degrees in a loop for a period of 6 seconds (360 milliseconds).

    The problem I'm encountering is when I press play in Unity to see what the game window looks like, the rotation jitters in some parts of the rotation in the same place every time. Originally the rotation time was 180 milliseconds so I thought maybe if I spread the rotation time out more it would help smooth it out, but it still jitters in the same place. Any ideas what could be causing this?

    Note I'm not using any c# script or the sort, just the built in components and object with our custom texture of our company logo, and this jittering occurs in the rotation animation.

    Update: Ok after pressing maximize on play and letting the game scene play out, it looks like the jittering is random, not consistent, so I don't know if it's because of the preview running on my machine that causes the jittering or not but it seems to randomly occur now. Note this scene only has 2 cubes and 1 sphere so it's not like I'm rendering a lot.
     
    Last edited: Sep 2, 2013
  2. TheCatProblem

    TheCatProblem

    Joined:
    May 26, 2011
    Posts:
    22
    Do you have two frames with the sphere at the same angular position (e.g., a frame at 0 degrees and one at 360 degrees)? This would create a "hitching" effect at the loop point, although this effect would always occur at that point and thus wouldn't explain the random jittering you've observed.

    If you just want the sphere to rotate without any additional animation, it's probably simpler to just write a quick script that rotates the sphere.

    For example:

    Code (csharp):
    1.  
    2. // This is C# code (I haven't tested it, but it should probably work)
    3. using UnityEngine;
    4. using System.Collections;
    5.  
    6. public class Rotate : MonoBehaviour {
    7.  
    8.     public float rotationSpeed = 30.0f; // Degrees per second
    9.  
    10.     void Update() {
    11.         transform.Rotate(Vector3.up * rotationSpeed * Time.deltaTime, Space.Self);
    12.     }
    13.  
    14. }
    15.  
    Reference page for Transform.Rotate.
     
    eovento and ForMiSoft like this.
  3. vinfang

    vinfang

    Joined:
    Jul 13, 2013
    Posts:
    14
    So what I did was create a sphere, put a texture on the sphere, and then created an animation object in Unity through the Window Animation and moving the keypoints so that it does a full 360 rotate in 6 seconds.

    Now using your suggestion, I created a script with the code

    Code (csharp):
    1. transform.Rotate(0, 1.8, 0, Space.Self);
    and the jittering is still occurring when I hit play and observe it in the game window. There are no frames or anything complicated, just a regular sphere created through unity with some text on it as the texture.
     
  4. TheCatProblem

    TheCatProblem

    Joined:
    May 26, 2011
    Posts:
    22
    Your script isn't accounting for the fact that the frame rate is unlikely to be constant (accordingly, Update() is unlikely to be called at a constant rate, e.g., it could be called 60 times in one second but only 54 during the next, which would change the speed of your rotation).

    In the sample I included in my previous post, the rotation rate is expressed in degrees per second and multiplied by Time.deltaTime (this variable gives the time spent executing the previous frame's operations) to make the rotation speed frame-rate independent. Whether the game runs at 30 or 60 frames per second, making use of Time.deltaTime ensures that the rotation will occur at the same rate.
     
    Last edited: Sep 6, 2013
  5. Deleted User

    Deleted User

    Guest

    Am answering the original question how to remove jitter from the animation. In the first frame, set rotation for say y=0, in the last frame set it to 360. Open the curves tab, and right click each key, set both tangents to linear. Basically the line should be straight.
    Unity Smooth Rotation.jpg
     
  6. stef07

    stef07

    Joined:
    May 20, 2017
    Posts:
    2
    Works perfect, I spent hours searching for a solution to my jittering propeller, thank u very much
     
  7. DryreL

    DryreL

    Joined:
    Feb 23, 2020
    Posts:
    31
    Thank you!
     
unityunity