- Home /
Making object fall over after death
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?
}
But you shouldn't need AddForce if you are using gravity and you just want it to fall. Just add a rigidbody Component>Physics>Rigidbody in the editor, then toggle Rigidbody.is$$anonymous$$inematic
Ill have a look into this later on in the week, thanks for the information! $$anonymous$$uch appreciated. I think I will be able to sort it out!
When you get a chance, if one of these answers has provided you a proper solution, please accept one of the answers and vote it up. If your issue hasn't been resolved, please let us know so that we can work with you to fix this.
Answer by Kyth'Pth3hk · Aug 05, 2013 at 07:43 PM
If you want to make it to simply fall down, how about adding a rigidbody, and then apply little force to it?
Do you know a simple way of doing this? Ill try search myself. But on my mobile. Cheers
Your answer
Follow this Question
Related Questions
Collision between objects 2 Answers
Moving an object 0 Answers
How does unity/javascript handle object references? 1 Answer
Collision Detection with object already in detection area 1 Answer
Getting a scene object's name 1 Answer