I have a simple rolling ball setup. However, I would like my ball to not roll down while moving along a slope’s surface. For illustration:

- The green arrow shows the path the ball takes when it is not controlled by the user
- The blue arrow shows the path that I want the ball to take when it is moved along the surface
- The yellow arrow shows the approximate path that the ball actually takes when moved in the direction of the blue arrow
How can I get the ball to follow the blue path when it is strictly told to move in that direction? (I need this to work at many different angles so freezing the rigid body’s rotation is out of the question)
I’m not sure if this will help much but here is the code to make the ball move:
void FixedUpdate()
{
float horizontal = Input.GetAxis("Horizontal");
float vertical = Input.GetAxis("Vertical");
float mouseX = Input.GetAxis("Mouse X");
float mouseY = Input.GetAxis("Mouse Y");
cam.transform.Rotate(Vector3.right * -mouseY * Time.deltaTime * 500);
player.transform.Rotate(Vector3.up * mouseX * Time.deltaTime * 500);
if (Input.GetKey(KeyCode.LeftShift))
{
speed = 10;
}
else
{
speed = 5;
}
rigidbody.angularVelocity = (cam.transform.right * (vertical * speed)) + (player.transform.forward * (-horizontal * speed));
}