Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Visible "stuttering" when moving object

Discussion in '2D' started by Kristen182, Jun 27, 2019.

  1. Kristen182

    Kristen182

    Joined:
    Aug 10, 2018
    Posts:
    42
    I can't seem to reduce very obvious stuttering when an object is being translated. My current setup is like this:
    -The camera doesn't move
    -Obstacles are moved toward the player by setting the velocity
    -The objects being moved have colliders and are kinematic.

    Other things I've tried:
    -I've tried turning on interpolate on the rigidbody
    -I've tried different ways of translating, like using transform.translate and integrating lerp
    -I've tried building my project to both android and pc and it doesn't go away, so it's not Unity Editor
    -I've tried setting the scale of my objects to 1, because they are shrunk quite a bit right now
    -I've tried following the "flappy bird" tutorial unity has, where each object has the "scrollingObject" script attached to it with the following code:
    Code (CSharp):
    1. public class ScrollingObject : MonoBehaviour
    2. {
    3.     private Rigidbody2D rb2d;
    4.  
    5.     // Use this for initialization
    6.     void Start ()
    7.     {
    8.         //Get and store a reference to the Rigidbody2D attached to this GameObject.
    9.         rb2d = GetComponent<Rigidbody2D>();
    10.  
    11.         //Start the object moving.
    12.         rb2d.velocity = new Vector2 (GameControl.instance.scrollSpeed, 0);
    13.     }
    14.  
    15.     void Update()
    16.     {
    17.         // If the game is over, stop scrolling.
    18.         if(GameControl.instance.gameOver == true)
    19.         {
    20.             rb2d.velocity = Vector2.zero;
    21.         }
    22.     }
    23. }
    With flappy bird, the stutter isn't as obvious at the speed flappy bird uses (-1f). But if you increase the scroll speed to -5f for example, it becomes very obvious.

    I'm a bit stumped. Is this behaviour expected? What can I do to make it go away?
     
  2. iodinex64

    iodinex64

    Joined:
    Mar 25, 2016
    Posts:
    7
    Is your rigidbody set to "interpolate"? That should smooth it right out.
     
    CitorsDev likes this.
  3. Kristen182

    Kristen182

    Joined:
    Aug 10, 2018
    Posts:
    42
    Thank you for the suggestion! I forgot to mention that as one of the things I've tried, I didn't see any difference with it on in this case.