Collision with Particle System (Laser Beam)

Hey All!

Im making a 3D top down shooter/survival game and im stuck on a minor issue.

Ive created a laser beam using a particle system, Its a straight line with one single colour, and comes out of the gun.

Seems to work fine and shows where the player will be shooting.

Issue i have is that the laser beam doesnt seem to interract with anything in terms of collisions. For example, in the picture below, you can see that the beam itself travels through the dummy target. It does similar things with walls and other objects.

Untitled.jpg

Is there a way to change the particle system so that it “stops” once it hits something?

Many Thanks!

I believe you need to to a line trace outside the particle system. if the ray trace has a “hit” then obviously you check to see if the distance is LESS than your beam length, if it is, then you reduce your beam length during that tick. You can do a line trace with blueprints or c++

Ive already got a line trace coming out of my weapons muzzle so the player can shoot in the direction that the character is facing.
Had to do it that way because its top down.
Would i be able to use the same line trace for the laser beam?

One way is like this:


He sets a start and end point for his laser beam particle.

For some reason that still doesnt work - The collisions work but IF theres nothing to collide with then the laser beam snaps to the center of the world.

Try using an if node in BP connected to collision, saying “If no collision or hit detection, then laser beam is x length”. Why would there not be collision, though? Like when the beam goes through an open door and doesn’t detect what’s in the next room yet?

Im basically just using it in place of a crosshair. i think it looks slightly nicer.
so yh id have a max length on the laser and only shorten the length then that hits a collider…

Little confused with your If Node method though.

This is whats currently happening - laser snaps to world center when theres nothing to collide with. It should just be one straight beam regardless
UE4Editor_iYbVOtV6JP.jpg

I don’t understand why it would snap to world center, either. Perhaps it’s in the camera’s settings, or the material’s coordinate space of the laser beam. There’s also the particle system defaults that may be doing it. With the If node, it’s based on comparing A to B variables. I was thinking in terms of basic logic, but forgot that the if node compares A to B and outputs based on the results (A > B, or A < B). Isn’t there an if-then capability in Blueprints?

ok so center of the world is just FVector 0,0,0. the reason why its going there is if you look at the final node (set beam target point) it wants you to feed it in a (new target point) which is a FVector. If you dont provide one, its going to just use 0,0,0, which is the center of the world.

So what you want is the players forward vector * some distance instead. (or at least the weapon barrel forward vector)

So in the blueprint there already is a playerfoward vector * maxlength that is being used for the line trace. one is plugged into start and the other end on the line trace node.

See if you can link the end (from the add node ) into the set beam target point (new target point). I’m at work so not sure if it will let you dual link but that should work as a default value.

basically your goal should be this. if there is a hit, then use that hit location as the beam end point. if there is not a hit (default end point) should be the exact same as the traceline end.

the player forward vector will work as long as the gun is pointing the exact same as the player. you can use either one of course, player forward vector or gun forward vector doesnt matter. if the gun is a different height then its better to use the gun for start and end points.

Okay from your message this is what i came up with which seems to work, If there is a blocking it then itll use the Location from the hit result as the end point of the beam, If not then it will use the Forward Vector * the Laser Length as the end point.

Same problem but none of the fixes worked for me…