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

Question rigid body jumping in place

Discussion in 'Physics' started by Zimaell, Apr 15, 2023.

  1. Zimaell

    Zimaell

    Joined:
    May 7, 2020
    Posts:
    329
    I make a controller on a rigid body and stopped at the next moment, the object jumps in place constantly, here is an example

    Code (CSharp):
    1.  
    2. if(!Ground){ MoveDir.y += -1f; }else{ MoveDir.y = 0f; }
    3. if(MoveDir != Vector3.zero){ // MoveDir is Vector3 x, z axis vertical and horizontal
    4.     RB.MovePosition(RB.transform.position + MoveDir * 4f * Time.fixedDeltaTime);
    5.     }
    that is, as planned, it should go down if there is no ground under its feet, while the ground is checked by a sphere under the collider (0.2 lower).

    I don't understand why he jumps in place...