Download

Particle System as "Bullet Tracer" | Needing additional information

Hey all! I am changing my weapon firing system from Spawning a projectile Actor to using a line traced system. The way I had it set up in the past was instead of using a mesh actor as the projectile, I used the particle system, which yielded the particle effect result I was looking for.

After no luck at adjusting the projectile hit location to be the center screen (crosshair location), I have since moved forward using a line trace system. The line trace system works as expected for causing damage, but I cannot for the life of me figure out how to use a particle system in conjunction with it.

I have found a few threads about creating a beam particle and have tried to manipulate it to fit my desired result, but have been unsuccessful.
I have found that I need two types of particle systems, one that can simulate a tracer effect (Particle moves from point A to point B) and a trail for sniper trail effects (a solid particle system from point A to point B).

So my two questions are
1: Is there a way to assign the hit location of a spawned projectile so that I can continue using the first method mentioned above?
and if not,
2: Are there any tutorial/write ups for creating a particle system like mentioned above in use with my new hit scan set up?

I am using the SciFi weapon pack from the marketplace with included particle systems.

I have looked over a few tuts out there, but they are not using a hit scan system and are attaching the particle system to the projectile that is responsible moving the particle system from point A to point B. (I was already using this method)
This is the link to one I have found, but again, it is not a hit scan set up:
https://wiki.unrealengine.com/Projectile_Visual_Effects

Any help on this would be well appreciated!
Matt

Why beam particle? Shouldn’t you use ribbon particle for a trail?

Ahh. Still new to particles and while I was searching the only tutorials I have found other than attaching a particle system to the actual projectile was over Beam type particle systems.
I will play with using a ribbon system and see if I can make any headway. I appreciate you for bringing this to my attention.

Matt

I remember why I used Beam… Because while I was having a look at the nodes related to particle systems, beam was the only one that had a source and target. In my mind that was the solution that would work.

I have spent a little time playing with a ribbons. I was able to create a nice looking effect, attached it to my weapon BP, set active upon custom event “FireWeapon” but the problem is that it continues to fire off the particle repeatedly. I want it to only fire off one particle per “FireWeapon”. Not to mention, that I cannot figure out a way to make it hit a given location assigned by my trace hit.

Frustrating! >:(

You want to use Beams for Hit-Scan weapons, since beams are ‘Instantaneous’, whereas Ribbons are supposed to be time-based an tend to follow something.

However, there are two ways of doing this. If you want your weapon to ‘appear’ as though it’s actually firing bullets, you may want to create a fake projectile using particles and in which case you’ll want a ribbon that follows another particle emitter as it’s leader. In Gears of War, all weapons are actually hitscan weapons, but the particles lead you to believe that they are firing real projectiles. It’s a balancing act, but it can look and feel really good (gears is a testament to good weapon feel IMO).

Alternatively if you’re doing lasers or something, or extremely fast-moving projectiles, a beam is probably more suitable. I can’t give you a perfect example, but this is how our laser beam is set-up for our Satellite. You can also use the 'SetBeamSource() and ‘SetBeamTarget()’ functions, but Distance was easier in our case since the beam is always straight. This is C++ I’m afraid, but the same functionality is available in Blueprint.

Essentially what the code does is a Line Trace out in front of the vehicle up to the max distance, then uses the hit location as the end-point for the beam. Looks more complicated than it really is. We know that the Beam is always going to be coming out the front of the Satellite, so we just set the ‘Distance’ of it. As I said, you can also ‘SetBeamSourceLocation’ and ‘SetBeamTargetLocation’ as well, and actually set the values directly, similarly to how we do the distance.



	// Perform a Line Trace that extends out in front of the craft.
	FCollisionQueryParams TraceParams;
	TraceParams.bTraceComplex = false; // Don't use Complex Collision
	TraceParams.AddIgnoredActor(this); // Ignore Self;
	FHitResult HitData(ForceInit);

	// Start / End Points
	const FVector SocketLoc = GetSatelliteMesh()->GetSocketLocation("LaserSocket");
	const FVector SocketDir = GetSatelliteMesh()->GetSocketRotation("LaserSocket").GetNormalized().Vector();
	const FVector SocketEnd = SocketLoc + SocketDir * SatData.Laser_Range;

	// TODO: Use ECC_Laser, otherwise we're constantly going to be tracing against everything, even Earth.
	// If the trace was successful.
	if (GetWorld()->LineTraceSingleByChannel(HitData, SocketLoc, SocketEnd, ECC_Visibility, TraceParams))

- Redacted -

	// Handle Laser Firing
	if (bWantsToFire)
	{
		if (LaserPS) //LaserPS = Laser Particle System ;)
		{
			const float HitDistance = FVector(SocketLoc - HitData.Location).Size();
			LaserPS->SetFloatParameter(TEXT("Distance"), HitDistance);

			if (LaserPS->IsActive() == false)
			{
				LaserPS->SetActive(true, true);
			}
		}
	}
	else if (LaserPS && LaserPS->IsActive() == true)
	{
		LaserPS->SetActive(false, true);
	}


And then, the Particle is set-up like so:

wot.JPG

EDIT: Also in terms of making the projectile fire repeatedly, ShooterGame has a nice toggle-able system where you can tell the weapon that the Particle is either looping, non-looping etc. If the particle is non-looping, it will spawn a new ParticleSystemComponent everytime you fire the weapon, and it’ll destroy itself automatically. Looping ones are a bit cheaper since you can just turn the same particle system on or off, but they’re a bit more finicky to get the timings perfect.

If you want a particle to only fire once during it’s lifetime, set ‘Emitter Loops’ to 1 in the ‘Required’ module. Note that the particle will only destroy itself if ALL ‘Required’ modules loop once, otherwise they’ll remain forever until they are killed off.

Wow! Thank you very much for this information! You’ve really gone beyond any answer I’d hope to have gotten! I am indeed using blueprints but I will start testing around and try to come up with something of the sort.
I will post my solution once I’ve got it squared away.

Again, thank you TheJamsh for the detailed reply!

Matt

Did you ever find a solution to this in blueprints? I could build something from TheJamsh’s description but I would be curious to see how you implemented it. :slight_smile:

I’m hoping you can toggle looping and non-looping and life span from blueprints as well. I have an automatic assault rifle so it fires bullets pretty rapidly.

I was previously spawning actors as bullets but it was causing major lag in my game. Especially with six AI units using automatic weapons at the same time. There will eventually be 40 units in the battle at a time so I really need a better system. Hopefully particle systems will solve the problem.