Hi! I have a machine gun in my game that have a FireRate of 0.1 (waits 100 milliseconds before shooting), and it shoots bullets with the speed of 100 (i guess Kmph).
My bullets are PLANES and they have rigidbody AND colliders, and i am using a script to delete them at any cost, here it is:
#pragma strict
var Coll = false; //Ignore this var, i don't even know why i made this, i am going to delete it soon...
function update()
{
yield WaitForSeconds (10);
Destroy (gameObject);
}
function OnCollisionEnter(collision: Collision) {
if (Coll == true) {
Destroy (gameObject);
}
}
function OnCollisionExit(collision: Collision) {
Coll = true;
}
Sorry for the poor explanation, i sincerely don’t know how to explain this properly. As you see in my script, it is supposed to make my bullets be destroyed when they touch ANY collider, and even if they don’t, after 10 seconds they were supposed to be destroyed. The problem is that the bullets are ignoring the script. The bullets aren’t being destroyed after 10 seconds, and some of them still continue existing even after hitting a collider. I have set the bullet prefab’s collision detection to continuous dynamic and STILL it doesn’t do anything. Can someone help me here? What am i missing?