Ok, so I have a sphere with a Rigidbody attached. When the ball hits an object, I want it to either bounce left or right at random. I know I can use Rigidbody.AddForce to make it bounce, but how can I have the script randomly determine which way?
use
var min : float = 0;
var max : float = 0;
rigidbody.AddForce(Random.Range(min, max), Random.Range(min, max), Random.Range(min, max));
realm_1
Or you can use:
rigidbody.AddForce (Random.insideUnitSphere);
Or:
rigidbody.AddForce (Random.onUnitSphere);
Depending on what you’re doing.
Then you can add an optional speed variable to change the force.
Got it. Thanks.
Cool, very helpful to me too.