Spawning a pawn inside a mesh component, detecting when it leaves

The task is as follows: the player spawns inside a cardboard box, which is a blueprint actor. I’d like to tell when the player leaves the box.

I thought it was easy: I just add a cube mesh component to the box, covering the empty space inside. Set its collision properties to overlap on all channels and then just wait for the EndOverlap event. When that happens then check if the “Other Actor” is the player and if so then I can conclude that the player has left the box.

The trouble is that it doesn’t work: I seem to get the EndOverlap event every single frame while the pawn is inside the trigger box.

Any advices?

Can you post a picture of your setup? Most likeely your capsule is collidding or your collission cube isnt setup properly. A few things to try,…

Increase the height (make it taller and lower than the cardboard box) of the collider cube
Change collisson settings
remove the other actor check
Add a getPlayerCharacter → Cast to yourCharacterBPName then right click on the blue reference pin and promtoe to variable called myChar and do a check otherActor == myChar into a branch
Add more print strings to see exactly whats going on

What I would personally do is move the collision box to outside the cardboard box so you dont get the issue of having to first enter it then exit it.

OR just forgo the collission area all together and just check get MyPlayercharacter → cast to yourcharacterbpname → promote to var → GetWorldLocation on a tick and compare to GetWorldLocation(box) and then use a isNearlyEqual with a large amount of varibility to check if you get close to it or you get far away going the opposite direction.

Hope this helps, a screenshot of your blueprint setup might help if those dont work.

Don’t forget to accept an answer that best clears your question up or answers it so when the community finds your question in the future via search/google they know exactly what you did to fix it/get it going.

It seems that the root of the problem was the root component which is a physics driven skeletal mesh with “Simulate Physics” turned on. If that flag is off then the end overlap event is fired properly, only when I leave the box. Surprisingly it ends up simulating physics too, I’m not sure why.

Ok so a different part of the game logic turned Simulate Physics back on all ragdolls, that’s why it was still simulating.
Enabling it right inside the class, on BeginPlay, after a ~1 second delay works too.