Search Unity

  1. We are migrating the Unity Forums to Unity Discussions. On July 12, the Unity Forums will become read-only. On July 15, Unity Discussions will become read-only until July 18, when the new design and the migrated forum contents will go live. Read our full announcement for more information and let us know if you have any questions.

Dealing with Jitter: Overcoming Character Movement Issues in Unity with Rigidbody

Discussion in 'Physics' started by unity_0951A74346160D125F28, May 12, 2024.

  1. unity_0951A74346160D125F28

    unity_0951A74346160D125F28

    Joined:
    May 12, 2024
    Posts:
    2
    I'm encountering an issue where my character in Unity experiences unexpected jitter in the Y-axis while moving. This jitter is unwanted and disrupts the smoothness of the character's movement. I'm utilizing a Rigidbody component for character movement. How can I resolve this Y-axis jitter and ensure consistent and smooth character movement


    but notice that, when is use only one plane for the ground, everything works fine. but with some ground i have this problem.

    i provide an example that you can download it.

    my code :

    Code (CSharp):
    1. public class PlayerMovement : MonoBehaviour
    2. {
    3.    public float moveSpeed = 6f; // The speed at which the player moves
    4.  
    5.    private Rigidbody rb;
    6.    private float horizontalInput;
    7.  
    8.    private void Start()
    9.    {
    10.        rb = GetComponent<Rigidbody>();
    11.    }
    12.  
    13.    private void Update()
    14.    {
    15.        horizontalInput = Input.GetAxis("Horizontal");
    16.    }
    17.  
    18.    private void FixedUpdate()
    19.    {
    20.        // Calculate the movement force
    21.        Vector3 movementForce = new Vector3(horizontalInput * moveSpeed * 2f, 0f, 0f);
    22.  
    23.        // Apply the movement force to the player's Rigidbody
    24.        rb.AddForce(movementForce, ForceMode.Force);
    25.    }
    26. }
    my rigidbody settings :

    Code (CSharp):
    1. Mass : 1
    2. Drag : 0
    3. Angular Drag : 0.05
    4. Garvity : Checked
    5. Is Kinematic : Unchecked
    6. interpolate : interpolate
    7. Colision Detection : Continuous
    8. Freeze Position : All Unchecked
    9. Freeze Rootation : All Checked
     

    Attached Files:

  2. unity_0951A74346160D125F28

    unity_0951A74346160D125F28

    Joined:
    May 12, 2024
    Posts:
    2