Detect if the player is getting crushed/stuck between two collisions

Hi!

I was wondering if there was a way to detect if the player is getting crushed/stuck between collisions, and then trigger a death. I don’t think there’s an ‘‘easy’’ way to do this, but maybe there’s a trick that I could use. Sadly, I can’t simply use OnActorOverlap, as it’s not just when the actor goes over a cube for example, I want this death to trigger anywhere when the player is getting crushed.

In my prototype, I have for example moving cubes that the player can activate, but when the player stands on them, activate them, and they go to the ceiling, the player only gets pushed to the side or go through the collision and fall out the world. He could also get ‘‘crushed’’ on different situations or angles, so I was wondering if there’s a way to detect that, when the player is getting ‘‘squished’’, let’s say. For example, that happens in Portal 2. Everytime you’re getting crushed, the camera backs up and shows the character exploding. I’m looking for something similar.

If you have any questions or need precisions, don’t hesitate!

Thank you!

Years late, and no reply, so I’m just going to write for anyone else who stumbles upon this:

Usually, you fake this sort of thing, and it’s not something that you realistically code for.
In the example that you mention of the player standing on a cube and being pushed into the ceiling, what I would do is have a Box Collision component as part of the moving cube blueprint that is placed at the ceiling height (either manually, or relative to the maximum height the cube will travel) and when the player overlaps this, you kill them. You just assume that the player is going to die instantly once they are crushed. Alternatively, if you wanted to code a system where the player can maybe push back against being crushed, or escape, then you’d want to just apply damage for every X time that the player is overlapping the box collision. You’d use an Event timer for this.