Player dies when actor collides with trap - help

My player keeps dying when my enemy collides with a box. The code is set up so the character will die when it hits the box, but when the enemy hits it instead, the character still dies. I’ve tried putting in a true and false statement towards the beginning but I am stuck! any suggestions??

Oh thank you! I’ve rearranged it so it looks like this

the character is still unfortunately dying when the enemy touches the trap. Would I add in a component regarding the enemy?

Hi, you’ve got your logic all screwed up there.

When ANYTHING overlap, the first thing you’re doing is casting the player pawn, well that’s always going to work :slight_smile:

You need to cast the ‘other actor’ to check it’s your enemy, if it is, then destroy your player.

oops sorry, this picture

Sorry, misread your text. If you want to kill the player when he overlaps use:

( except you cast to your 2d character… )

If what you want to do is to kill the player character whenever player overlaps with the box. what you are doing now is bit off from the actual solution. Branch that you are executing is always true and it is never going to execute that casting to enemy character and destroying it. you can actually remove that branch statement completely and connect that other actor from “On Component Begin Overlap” to cast to 2DSideScroller. That will give you the functionality you want (kill player when he overlap with box).

I Hope this helps you Cheers!

Thank you for your help! I think it might be the enemy code doing something as it works great without it :slight_smile: