Hey, is there a way to use OnTriggerEnter2D but it only detects 2D Box Colliders?
I have a script that detects when the enemy loses health from a Sword. But I have two colliders on the enemy. Anyone think they can help? I want OnTriggerEnter2D to only detect 2D Box Colliders. Thx
Here is my script:
void OnTriggerEnter2D(Collider2D other) {
if (other.tag == "WSS" && SS.WSSA == true && damaged == false)
{
health = health - Random.Range(statsScript.weaponShortSwordMinDamage, statsScript.weaponShortSwordMaxDamage);
damaged = true;
Debug.Log(health);
}
}
Picture of my scene:
[28135-screenshot+(54).png|28135]
Pyrian
2
Just add “&& other is BoxCollider2D” to your if statement.