Hi, I’ve been trying really hard to get this part of the script to work but I just don’t understand why it wont work here are my scripts:
The one that works:
void OnCollisionEnter (Collision other)
{
print("hit");
if (other.gameObject.tag == "Bullet")
health -= 1;
}
The one that doesn’t:
void OnCollisionEnter (Collision other)
{
print("hit");
if (other.gameObject.tag == "Player")
Destroy(gameObject);
}
What I did was put both of these scripts into one object and let the player just run into it. It prints out “hit” only for the first script but not the second. I took out the first script and when testing it again no hit is printed.
I have boxcolliders in both of my objects and 2 rigidbodies. One stands still the other (the player) runs into it.
I do not understand why the second script prints nothing. Any ideas?