Hello, I’m having trouble setting up the physics for spheres. They will bounce off a wall, then keep rolling very slowly forever until they hit something again.
Is there any way to fix this without adding scripts to all my spheres? Or should I just not use them?
It doesn’t seem to matter what I set the friction or angular drag to. Either I have the mass so high it just lands and doesn’t roll, or it rolls forever. There’s no in between.
In the sphere’s physics material if you set bounce to zero and ‘Bounce Combine’ to minimum then the sphere will stop when it hits a wall, but only if it’s not on a slope. If the sphere is on a slope then gravity will always roll it down the slope.
Somebody recently had an issue trying to simulate a golf ball and to prevent the ball from rolling down a slope I had to cancel out gravity like so:
using UnityEngine;
public class GolfBall : MonoBehaviour // simulates a golf ball on grass. Unlike friction or drag this will bring the ball to a gradual stop even on slopes
{
Rigidbody rb;
void Start()
{
rb=GetComponent<Rigidbody>();
}
void OnCollisionStay(Collision c)
{
rb.angularDrag=1;
rb.AddForce(-Physics.gravity-rb.velocity*0.9f); // cancel out gravity and gradually bring the ball to a stop
}
}