Hitboxes Not Working When Players are Too Close?

Hello everyone,

I am currently working on a fighting game in Unreal Engine 5.4, and I’ve encountered a baffling little bug.
To summarize my situation, I have one custom player pawn that is able to create hitboxes, and have collision detection code tied to an OnOverlap event that handles both player and hitbox collision logic. Both players are an instance of this one player pawn class, so the logic should be consistent in the way that it operates between both pawns.
When the players are a considerable distance away from each other, the hitboxes resolve correctly, the hit player enters the hitstun state and takes damage as expected; however, when the players are close, the logic for the hit resolution logic fires, but the player does not enter the hitstun state or takes damage as expected as shown in the first screenshot. Worth noting is my debug PrintString does fire to prove that the logic does fire as expected, as shown in the second screenshot.


Worth noting is that, in the second case, the players should, in theory, not be overlapping due to how the collision code is implemented (unless there is something I am fundamentally not understanding about the OverlapBegin event). Why would the hitbox resolution logic fire both when the players are spaced out and close (potentially not touching) but will only update when there is a good amount of space between both players? Below I have posted the collision code, if it helps.

Thank you so much for taking a look at this problem.

Hey @Cleeeps!

This code… Is a little confusing so let me ask a few questions to clear things up to help you better!

You’re doing a Cast to BP_Hitbox for anything that isn’t the player that is overlapping, then if it’s NOT a BP_HitBox, you cast the element to the enemy player? That’s two collisions, but it’s unnecessary, also it seems like you might mean “HURTbox”? Hitboxes are attacks, hurtboxes are soft points so if you’re using the name for both attack and defense you may want to clear that up. Because it seems like all of your health reactions are on the Hitbox cast.

All of that being said you may want to switch to using “Box/Sphere Trace By Channel” and seek Pawns. You’re trying to use an overlap for quick scanning but if you’re creating this on the fly it might not be functioning correctly.

Hope this helps, get back to us! :slight_smile:

Hey @Cleeeps!

Did you end up figuring it out? Let us know for future answer seekers who may have run into this!