Event Hit does not trigger when player is not moving

I am working on a 2.5D side scroller project and I have been trying to make it so that when the enemy collides with the play a health loss function is called via event hit but for some reason it only triggers when the player is moving. I am only using blueprints for this and I am working in UE 4.19.1.

This is the blueprint for the enemy. All there is to it is a cube which has my object type Enemy and a script that moves it each tick. The sphere is used for something unrelated to player collision and only overlaps with the player.

This it the part of the players blueprint that checks if it is colliding with and object of the type enemy, if it does then it calls the HealthLoss function and then waits a set time before allowing the player to be damaged again. As you can see the players capsule component is of the player object type and it is set to block enemy.

But as you can see in this video event hit does not trigger as long as the player is standing still even though the enemy is moving into the player and pushing it.

Does anyone know what is happening here?

To be clear I have found a workaround to this by manually adding box collision to the enemy and checking for overlap instead, so this is not request for a new solution to doing collision but rather I would very much like to know what is going on.

As you’ve noticed, hit events do not fire unless there has been a change in movement. One of the ways to check against certain objects to determine if there is a collision is to do an overlap check.

Have you tried doing something similar to the image below? You can do a capsule overlap check against certain object types (Enemy) or class types. If you find an object you can either do something for each object in the loop or break out after a health drop.

Hey Velrin, as i said at the end of my post I have a workaround using the “On Component Begin Overlap” in stead of the Event hit in player and adding a box collision to the enemy and making it a bit bigger than the box it self.
But is it just how Event Hit works? That it only triggers if there has been a change en movement?

In my experience, yes. A hit event only triggers when a move has been detected. I hesitate to give an absolute answer without having the exact source code in front of me or an UE4 document declaring so.

Just took a look at your video and I did not realize that the box was moving into the player. In that cast a hit event should have been triggered for the player.

Exactly. Which is why I am confused that it does not. It also makes no difference if the hit detection is in the player or enemy since with break points in both non of them trigger.

I Think you need to enable Sweep at the set actor location.

According to http://api.unrealengine.com/INT/API/Runtime/Engine/GameFramework/AActor/SetActorLocation/index.html:

Whether we sweep to the destination
location, triggering overlaps along
the way and stopping short of the
target if blocked by something. Only
the root component is swept and
checked for blocking collision, child
components move without sweeping. If
collision is off, this has no effect.

That makes event hit trigger like i thought it would, although now it can’t push the player. However now when I turn sweep back off the enemy completely ignores the player just passing through him unless he moves. This is weird since the blueprints are the same as the original post.