Is there a way to detect crushing a player?

Is there a way to detect if the player is getting crushed between two assets? I honestly can’t figure this one out. I also can’t really cheat though it by simply using a simple collision detection. I need to figure out if an object capable of crushing the player, even if it isn’t moving all that fast.
Any suggestions?

To add additional Detail: This needs to be quite dynamic and I will likely need to implement more systematic methods of calculating when a player should be crushed by an object. Since my objects can have different velocities, weights, movement directions, and also inherit the unpredictable nature of simulated physics, I am going to opt for a less contextual method.

1 Like

I’d say crushing will certainly result in Collision Capsule’s clipping through one or another object, be it a wall or a rolling boulder or anything else. So you can place a smaller capsule inside the main one and if it overlaps anything but the main capsule, it means there’s not enough space for the character between two objects and he is probably being crushed right now.

Sadly this doesn’t work. My Physics are quite tight, and I don’t get clipping. None of my physics assets clips through the player capsule, they just stop upon impact.

Now you’ve got me confused. You want to detect player crushing, but the crushing never actually happens? How is that supposed to work then?

If I drop a five tonne physics object on my player, it should within all reason crush and kill them, because it’s a five tonne weight. But it wont clip through the player.

I wouldn’t want it to clip through my player anyway, since I don’t want a glitch dictating my game mechanics.

The way I imagined it would work is that there would be some sort of method to detect the oncoming force, dynamically detect if I am up against another surface, and have a threshold of crushing force to kill the player, I just don’t know how I would calculate that or if it’s even possible. I don’t know “how that is supposed to work” that’s the whole reason I’m on Ue4 answerHub asking in the first place.

Velocity check of the crushing object to see whether it’s above the threshold of negative Z (i.e. going fast enough downwards) and a collision detection between the object and the player’s head ought to do the trick.

Hi, this sounds like a step in the right direction, I will give it some tests, but might have to try and factor in other variables such as the weight of the object, calculating the momentum, and also the velocity of the player.

But in order this this to work, do you know how I could determine if the player is being crushed up against something? A huge block pushing the player from the side shouldn’t within all reason kill them outright unless it is pushing them into a surface and crushing them, do you know how I would detect such a thing?

You can use multi trace in the direction of movement to detect the character first and then if there’s something behind him, and get the distance between the character and the surface.

I think you would want to put this within your player blueprint. Depending on the size of your objects, you wouldn’t want your player to die from a piece of paper falling on them. Therefore, whenever a collision between the player and an object occurs, you want to check the size of the object with “GetComponentBounds” or “GetActorBounds”. If the object is bigger than whatever threshold you set, you can kill the player or deal damage based on the amount over the threshold that the object is (e.g. 5% over = 10% hp damage, 50% over = death).

For a sideways crush, I would do the same thing but for both objects, then determine the direction that the crushing object(s) are moving. For example:

  • If both objects are moving towards the player and are colliding with the player, AND exceed the threshold that I mentioned before, then the player will die.
  • If one object is moving towards the player and is colliding with the player BUT there is no other collision, move the player in the direction that the object is travelling.
  • If one object is moving towards the player and is colliding with the player AND there is another collision object BUT the other object is not moving, do a check to see whether the second object is above the threshold and deal damage based on the size and velocity of the initial moving object.

Just a few ideas.

Edited for clarity.

Fantastic, I will give these a go and update you on my progress. Cheers!

Hi Chyros, thank you for the suggestion. Unfortunately my system needs to be quite dynamic and I will likely need to implement more systematic methods of calculating when a player should be crushed by an object.
Since my objects can have different velocities, weights, movement directions, and also inherit the unpredictable nature of simulated physics, I am going to opt for a less contextual method.

I will definitely keep your method in mind, for if I decide to utilize hazards later in the game with my restrictive movement, your method could work in a pinch.

You should have mentioned that on your question. Here’s how I would check the force from an incoming object:

I did say “I also can’t really cheat though it by simply using a simple collision detection. I need to figure out if an object capable of crushing the player”. But none the less, I have added more details to the question for the time being.

Yes that’s why I posted above how to compute force on hit which involves mass and velocity.