I’m trying to write a piece of code which makes a gameObject, lets say a cube to fall after it’s taken a set amount of damage.
Can I either use Mathf.Lerp or something to smooth the process of the fall? Or apply a rigidbody depends on a hit force applied when the object dies?
(I have another script which raycasts for hitting the object)
#pragma strict
var health : int = 100;
var cube : Transform;
function ApplyDamage (damage : int)
{
Health -= damage;
if(Health <= 0)
{
Dead();
}
}
function Dead()
{
// Can I have a smooth transform for the object to effects it's position?
Mathf.Lerp?
}
If you want to make it to simply fall down, how about adding a rigidbody, and then apply little force to it?