I have this script to shoot a cube, I have it set up so upon hitting the player. Known as wall, it waits one second then destroys itself. What I want to know how to do is edit this code so if it doesn’t collide with the player, or collides with anything else it waits 5 seconds then destroys itself, here’s what I have:
Bulletcollision.js
var damage = 5;
function OnCollisionEnter(theCollision : Collision){
if(theCollision.gameObject.name == "Wall"){
//take 5 points from health of the wall
Player.health -= damage;
yield WaitForSeconds(1.0);
Destroy(gameObject);
}
else
yield WaitForSeconds(5.0);
Destroy(gameObject);
}
Thanks ahead of time guys!