How can you create a realistic bounce effect using scripting?
I know you can do a rigidbody.AddForce but that wouldn't be realistic.
How could you make it so that depending on where an object bounces it will bounce off in different directions.
BTW: Object bounces of a circular substance (if that matters).
This user simply copied the answer from here:
http://answers.unity3d.com/questions/3467/ball-going-against-wall-physics
Either provide a link or write your own answers. Normally I wouldn't think of editing an answer like this, but your copy & pasting isn't acceptable, and this isn't the first time you've done it.
I have been using this formula
#pragma strict
var firstTimeVelocitySave = false;
var savedVelocity : Vector3;
var myRigidbody : Rigidbody;
var BounceRate:float =1.5;
function OnCollisionEnter(col : Collision) {
//print("Collision! " + rigidbody.velocity);
if (! firstTimeVelocitySave) {
savedVelocity = rigidbody.velocity;
firstTimeVelocitySave = true;
}
myRigidbody.velocity.y = savedVelocity.y;
savedVelocity.y=savedVelocity.y/BounceRate;
}