How to make particle sparks shoot out in direction shot came from?

I’ve done a lot of tutorials on creating and applying particle effects, and searched for answers to this question, but I haven’t found any yet. I feel like I’m just missing something super obvious.

I have created a particle system that generates sparks and a puff of smoke when a gunshot hits one of the robot enemies. My problem is that the sparks shoot out at weird angles and not back in the direction that the shot came from. How do I make it so that the sparks will shoot out in the direction the shot came from?

Create a system that emits particles in one direction (X, for example). Then I assume you’re doing a linetrace. Take the hit location and use that to spawn the particle emitter and use the impact normal as the rotation (might have to negate the vector). I haven’t tested this myself because don’t really have such particles but it should work.

Thanks for the reply! I plugged Impact Normal into Rotation, and it definitely looks better but still isn’t quite right. How do I negate the vector? (I’m not sure what that means exactly)

Thanks for the reply! I plugged the impact normal into rotation, and it definitely improved the result I’m getting – but it’s still not quite right. How do I negate the vector (and what does that mean)?

Use the FHitResult::ImpactNormal.

Here’s an example of spawning a particle emitter facing in the direction it came from in C++:

FHitResult Hit = ...; // This is the FHitResult you get from something like GetWorld()->LineTraceSingleByChannel
UParticleSystem* ParticleSystem = ...; // this is your particle system
FRotator const Rotator = FRotationMatrix::MakeFromZ(Hit.ImpactNormal).Rotator();

You can achieve the same thing in Blueprints with the corresponding function LineTraceByChannel.

1 Like