Hey guys!
In my game I have a player who shoots a bullet and an enemy who is patrolling around. The enemy patrols between two empty gameobjects which mark the range of the patrol. The problem is that these objects must have box colliders so that the enemy stays within this range. They also have a tag. I have Collider2D on my bullet in the OnTriggerEnter2D function.
Now I found this option so I can let the bullet ignore the gameobjects but in the ignoreCollision function I need to refer to the gameobject. How do I get it? What should I put instead of “theobjectToIgnore” in the physics function? I hope you can help me out and kind regards!
if (hitInfo.gameObject.tag == "theobjectToIgnore")
{
Physics.IgnoreCollision(theobjectToIgnore.collider, hitInfo);
}