Rolling on collision

I’m having a small issue where if I collide with another object (let’s use a simple cube) with my player (this player is just a sphere), the ball will infinitely roll in the opposite direction and WILL NOT STOP. my code is as follows:

using UnityEngine;  public class PlayerController : MonoBehaviour {     private Rigidbody rb;     private float moveHorizontal;     private float moveVertical;      public float moveSpeed;         // Start is called before the first frame update     private void Awake()     {         rb = GetComponent<Rigidbody>();     }      // Update is called once per frame     void Update()     {         moveHorizontal = Input.GetAxis("Horizontal");         moveVertical = Input.GetAxis("Vertical");     }      private void FixedUpdate()     {         MovePlayer();             }      private void MovePlayer()     {         Vector3 movement = new Vector3(moveHorizontal, 0.0f, moveVertical);         rb.AddForce(movement * moveSpeed);     } 

I even changed the ForceMode to ForceMode.Impulse so be able to see what it was doing a little easier, and it is in fact slowly rolling away infinitely with no way to stop it.

Both objects have a Rigidbody for them to be able to react to being hit. This is my first time messing with 3d. I tried to do something like this to make it not roll away on impact

private void OnCollisionExit(Collision collision)     {         if (collision.collider.gameObject.layer != LayerMask.NameToLayer("Ground"))         {             rb.velocity =;         }     } 

But then if I want to jump on the cube (lets say the cube is an enemy and I’m jumping on it to kill it), then it acts very wonky each time it touches the edge of the cube and I haven’t made it on top (again, because the velocity is being set to zero). I am all out of ideas and would love some input here!

EDIT: I now realize that the ball will slowly roll forever even without collision and just simply moving. I am very lost !