• News

• Industries

• Learning & Support

• Community

• Marketplace

# Help me with my Third Person Shooter blueprint (Line Trace)

I made a simple Line Trace Channel blueprint to test a shooting mecanic. The principle is pretty simple; I trace a line from the camera viewpoint (with a little offset) to set the location where the player is looking at, then a second trace line from the Mannequin’s head to that point. I have also put an explosion animation at the end of the line trace to confirm the hit, accompanied with an explosion sound.

Everything works fine except that sometimes, the explosion doesn’t occur normally. The explosion appears at another location (wich I presume is 0,0,0). I also hear the explosion sound when this happens. It seems so random I have no idea why it’s not working. Sometimes it works normally, sometimes it doesn’t, depending on where I am aiming at (wich doesn’t makes sense to me). I tried shooting at 20 different spots on a wall and, it goes like this : Works, works, doesn’t works, works, doesn’t works, doesn’t works, doesn’t works, works, etc. It’s really random (and depending on where I’m aiming).
If I keep shooting at a spot where it didn’t worked, it will never work.

I put some images of the situations and my blueprint if someone can help me out looking at those. If you need further explanations just ask me !

Thanks.

What the Line Traces look like.

What it looks like when it works.

When it doesn’t work (you can see the light of the explosion on the blocks).

I’m aiming at another location, but the explosion still appears at another location (not sure it’s 0,0,0 but I’m guessing it is).

The Blueprint.

So, I would guess that because you are ending the line trace and the point where the other trace impacted, your trace will actually come up short. You’re not getting a hit result because your trace stops just a tiny bit before it hits. This could be due to rounding in the float of each vector. Get the actor forward vector, multiply 10ish and add it to location vector going into your second trace. Let me know if that works for you.

As James suggested, your traces are short, and theres no hit result, and the explosion spawns at Vector(0, 0, 0).

Increase your trace distance also check if there was a hit.