Grenade cover detection

I am working on a grenade system but players can get damaged while being behind a wall I searched and saw that I have to use a line trace to verify if the player is behind cover or not but I can’t have it to work if I have more than 1 player in the explosion range.

If somebody could maybe give me an exemple of line trace to verify, that would be much apreciated! :smile:


This is my grenade system.

The code you showed has no linetrace. What have you tried? One simple way would be to: Once you have found all your potentially hit actors with the sphere overlap. You run a LineTrace from the grenade origin to one or more points of each individual potentially hit actors, if at least one is not obstructed, The actor was hit. You want to use multiple points to make sure that a waist-height wall, is not fully obstructing the actor. Ofc this can be as easy or complex as you want, but it gets really tricky once you want it “animation frame” perfect, which is most of the time unnecessary.

Thanks for the reply!

This is the line trace I talked about but as it didn’t work I did not send it.

Could you explain to me how can I run a line trace to more than one point or maybe more than one line trace?

I’ll be honest I’m still a noob in Unreal so… :sweat_smile:

I can try to send a screenshot of the whole blueprint if needed but its kinda big…

The blueprint was to big to take a screenshot so I put it here Grenade system posted by anonymous | blueprintUE | PasteBin For Unreal Engine if it helps

Thx again!

Could you explain to me how can I run a line trace to more than one point or maybe more than one line trace?

There is no magic involved, you literally do multiple line trace calls. Here is dummy BP that should visualize what i mean.

Ofc you can use Linetrace by channel, and store the hit component to apply your forces. The general idea stays the same.

Hi there,

If you are trying to trace characters behind a wall from a grenade, make sure to set a “multi-sphere trace for objects”, and object type Pawn (assuming player’s capsule is using the default “pawn” settings), and set the trace radius as equals to your grenade damage radius.

Hope that clarifies.

In case it might help… I use this mostly for line of sight to get pawns that I expect to be partly occluded:
GrenadeLoS

Up to 4 traces per target: left, right, top and bottom bounds with a small offset toward the center.

Imgur

1 Like

Thank you guys for your help but as I still wasn’t able to make this system work, I switched to the Radial Damage with Falloff wich worked great.

THX again for the help!

1 Like