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!
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.
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.