07-12-2012, 11:49 AM
Codice:
var bounce : boolean = false;
var bounceAmount : float = 10;
var Player : Transform;
function OnCollisionEnter (other : Collision) {
if(other.gameObject.tag == "Player") {
bounce = true;
}
}
function Update () {
if(bounce) {
Player.rigidbody.velocity.y = 0; Player.rigidbody.AddForce(0,bounceAmount,0,ForceMode.Impulse);
bounce = false;
}
}
t detects when the 'Player' (defined by you) enters the objects collider (aka hits it) then sends him into the air. Though this may not be the best way to handle it, it will work until someone with more experienced helps you.