Hi I need to know how to destroy a gameobject on collision. For example, I have a project that the enemy is a robot so I need to know when the robot gets hit with my players bullet three times it dies, I know its an OnCollision script, but I don’t know how to make it work. And please let me know whether the script goes on my robot or bullet.And it I need it so that it only gets destroyed when it collides with my bullet(the tag on the bullet is “Laser”). Thanks so much
On your bullet:
function OnCollisionEnter(col : Collision){
col.gameObject.SendMessageUpwards("DestroyRobot", SendMessageOptions.DontRequireReceiver);
Destroy(gameObject);
}
On your Robot:
function DestroyRobot() {
Destroy(gameObject);
}