I want to make my player can cross the enemy, using Physics.IgnoreCollsion
, but still, I want to detect when they collide to call a function that gives damage to the player
Thats when you use the “isTrigger” box on the colliders! Click the box and use
void OnTriggerEnter2D (collider other)
{
if (other.CompareTag("Enemy")) // for this to work, you have to set the tag of the enemy gameobject to "Enemy"
{
// damage player
}
}
More infos here:
BUT, if your enemies and player have a rigidbody, then use a second collider with “isTrigger” disabled and ignore.collision
on
Idk if that works, didnt test it, but according to my logic, it should ^^’