Hi all,
First time poster, forums have been a great help to me.
I have encountered this issue, and after trying a few combinations I need to ask for help!
I want to compare tag with the object I’m colliding with, I have the below code, but it seems to just ignore all collisions, let alone whatever I want it to collide with, my debug log also does not come up in console.
If you’re wondering why I play with gravity, i have a floating companion that I use as a grenade.
If i remove the If statement everything works as intended, but it will obviously instantiate my explosion on every contact.
TLDR: want instantiation to happen only with collision with Enemy tags.
void OnCollisionEnter(Collider col) {
if (col.CompareTag("Enemy"))
{
Instantiate (explode, location.position, transform.rotation);
Debug.Log ("awake");
}
rbody.useGravity = false;
}