Search Unity

jittering rigid body

Discussion in 'Getting Started' started by theslavegg, Apr 12, 2023.

  1. theslavegg

    theslavegg

    Joined:
    Apr 12, 2023
    Posts:
    1
    Hi, i started unity not that long ago and i came across an issue the movement for my enemies is jittery, can you tell me how to fix that?
     
  2. halley

    halley

    Joined:
    Aug 26, 2013
    Posts:
    2,445
    There's essentially three ways to move physical objects.

    You're combining the transform positioning of
    Transform.LookAt()
    with the physics system positioning of
    Rigidbody.velocity
    . Add some collisions between the yellow blocks, and you're sure to get jitter because the Rigidbody will fight your updates to the transform.

    If you want things to be handled by the physics system, avoid writing to the transform. Use Rigidbody methods, either by controlling motion directly with .velocity/.angularVelocity, or controlling motion indirectly with .AddForce()/.AddTorque(), ideally choosing one set over the other.