Hello! I am working on a 2d platformer, and I am working on my enemy blueprint. I am trying to find out the best and most reliable way to detect for ‘hit on head’ impact. I have tried multiple things, and am currently iterating through a version of this;
Enemy is a paper2d character. It has a ‘box collision’ scaled proportionately to the sprite size placed above the capsule collider, and on the player bp (also a paper 2d character), there is a box collider on the ‘feet’. On the enemy I do an on overlap, check if the item is a foot collider and if so, kill.
I also have collision set on the capsule so if the player touches the collider, it causes damage to the player. The two collisions are interfering with each other (That is, when i jump on the head it kills the enemy, but it also triggers the capsule collision which hurts the player).
I am trying to find the most optimal way to allow the player to get hit when touching the enemy on any side except the head, and can’t seem to figure it out. I am trying to avoid using a line/sphere trace when the player is ‘not on the ground’ as I was told that traces on tick are super heavy in resources.
Any suggestions on what I could do to make it cleaner, and not cause so many issues?
FYI, I don’t like the look of ‘hit and stop’, so I made the two actors overlap each other, so theoretically the player could go ‘through’ the enemy, but since they get knocked back on hit, and the enemy dies when jumped on from the top, they shouldn’t ever go through each other.