I’m making a platformer where you have a melee weapon that you swing, and any enemies that you hit get damaged by your weapon. Only problem is that unity will register that as the player getting hit, and kill the player. Is there a work-around that allows the child’s trigger to register differently than the player’s? I still want the weapon to collide with the enemy, just react to it differently.
Compare the tag or name in the collision method:
OnTriggerEnter2D(Collider2D col)
{
switch (col.gameObject.name)
{
case 'Body': DoStuff(); break;
case 'Weapon1': DoStuff(); break;
case 'Weapon2': DoStuff(); break;
}
}