Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

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.

Product Version: UE 4.19
more ▼

asked Feb 13 '19 at 05:16 PM in Blueprint Scripting

avatar image

173 8 16 19

avatar image Tuerer Feb 13 '19 at 05:30 PM

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.

avatar image Raxs_Slayer Feb 13 '19 at 10:15 PM

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.

avatar image Tuerer Feb 14 '19 at 07:14 AM

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?

avatar image Raxs_Slayer Feb 14 '19 at 10:24 AM

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.

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

1 answer: sort voted first

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.

more ▼

answered Feb 14 '19 at 11:09 AM

avatar image

36 1 2 6

avatar image Raxs_Slayer Feb 14 '19 at 11:16 AM

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?

avatar image Tuerer Feb 14 '19 at 11:23 AM

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.

avatar image predspread Feb 14 '19 at 11:33 AM

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.

avatar image Raxs_Slayer Feb 14 '19 at 11:35 AM

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

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question