What’s happening is when I fire my prefab gun, it doesn’t destroy the "enemy"s, unless I use this script:
function OnCollisionEnter(collision : Collision) {
Destroy(collision.gameObject);
}
I use this script on the prefab bullets and I can manage to destroy the enemy(clone)s. However, sometimes this results in a ricocheted bullet hitting the terrain and causing the world to disappear. I tried to use this script:
function OnCollisionEnter(collision : Collision) {
if(collision.gameObject.tag == "Bullet")
Destroy(gameObject);
}
However, this failed to work, I checked and made sure each model has a rigidbody, the bullet, the first person controller, the enemy, and I checked and made sure none were checked as triggers, and each model has their own collider. Can someone help explain why is this script not working?
I’d like to make it so that the first person controller can be destroyed when the enemy collides with it as well, is this possible?
Thanks!