So I am relatively new to the Unreal Engine, and I need some help on this specific point that I’ve been stuck on for days.
I want to make an explosion effect, but I don’t want it to affect any of the actors located behind solid objects. To do this, I have created a line of sight check (using the line trace) that returns all actors that are blocked behind solid objects. These actors are then sent into an array where I have hoped that I could ask for an exception from the radial impulse.
The problem is that I can’t get this to work. I’ve spent a lot of time looking for a solution, but nothing ever seems to work. Is there a way to make the radial impulse ignore specified actors, or another way to achieve a similar effect (where the actors in range that are not in the list are pushed away)?
Here’s a cheeky idea. We’ll be dealing damage instead:
- we deal radial damage will falloff on click
- Damage Prevention Channel is set to
- the wall’s object type is set to
World Static as well, it will prevent all damage
- upon receiving said damage, the physics simulating actor does this:
- untick Vel Change if you want the mass of the object to be taken into account; if you do, you’ll need to crank up the damage value by an order of magnitude, though.
Explosions on one side of the wall do not affect the objects behind it. Do tell if this is good enough. There’s probably more than one way to handle this. At least you do not need to faff around with traces, arrays, the damage falloff is already included and the built-in interface communications is a breeze.
And if you really need to
Ingore (some additional)
Actors, there’s an array pin on the node for that.
That works really well for my movable props, but what about characters, such as the player? It seems not to work and enabling the correct physics makes the model bounce around the map uncontrollably (which is understandable)
enabling the correct physics makes the
model bounce around the map
uncontrollably (which is
Aye, sounds about right - characters & physics interactions is a completely different can of WORMS. What should normally happen when the blast hits characters? They get pushed away? They go into ragdoll mode? An animation triggers?
They get pushed away from the center of the explosion, with the force being determined from their distance to said center
Try this instead for character only, no need to enable physics on the char mesh / capsule:
Should be good enough for shoving them around.
force being determined from their
distance to said center
This is handled by the
Damage Received (has falloff calculations), but you can use the actual distance and do your own multiplier, too.
That works almost as intended! The only (last) problem I am finding is that it keeps throwing me in a nonsensical direction.
So I may be in front of the grenade but instead of propelling me away from it (radially speaking from it’s origin), it always seems to push me in one direction
Do a GetActorLocation on your character - a GetActorLocation on your grenade (to get the vector from the grenade to your character), maybe add a little bit of Z to shove them upwards too (you can also turn the vector to a rotator and add some pitch if you want to change things in Degrees instead), Normalize it and then multiply by the strength that you want your impulse to have (1000 should be reasonable)
That seems to work for me! I just needed to bump up the impulse strength (since my character is “heavier”).
I’m assuming that for all objects that I want to have moved by an explosion (using the impulse) will need these settings applied to them, correct?