How do i make a Character/object bounce using Javascript?

what javascript can i use? and will the bounce script work with other objects aswell as the character?

Iv had an answer previous but im still finding it hard to set the bounce on an object.

thanks for the support !

You could add an collider, assign a physics material and set its bounciness to 1.


Look at the Standard Assets/Physic Materials folder in your project. There are some example materials (There is also one called "Bouncy".). One of the properties is bounciness.

The collider depends on your mesh geometry. For a ball you should use a sphere collider.

I have been using this
#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;

}