FirstPS Hitscan: Muzzle to Crosshair
I'm building a hitscan rifle using two line traces. The first line trace goes from the first-person camera directly out along its forward vector a scaled length. The second is supposed to go from the muzzle of the gun to the hit location of the first. Basically, the first line trace is for aiming. The second line trace is for the hitscan "projectile's" trajectory.
For the second line trace, I plugged in the hit location of the first (Let's call this the "Target") as the "End" and the muzzle of the gun as the "Start." It worked! Sort of...
About half of the shots weren't registered as hits for the second line trace. I assume the problem was that the length of the second line trace was at the cusp of hitting the target painted by the first. Sometimes the computer's number crunching would round a float up and I'd get a hit, and sometimes it would round down, and I'd get nothing.
So I'm trying to extend the second line trace's length and my vector math is a bit rusty.
I made a unit vector by subtracting the location of the muzzle from the location of the first hit (The Target) and normalizing it. Multiply the resulting unit vector by a big enough float and I've got my "End" location for my second line trace, right? I set it up in my blueprint and it's not working. Either my math's wrong, my programming's wrong, or my understanding of a line trace is wrong.
asked Feb 07 '17 at 04:58 AM in Blueprint Scripting
The vector you are getting then needs to be be added to the "start" vector. Also I don't think you need to substract your muzzle location.
answered Feb 07 '17 at 06:08 AM
Follow this question
Once you sign in you will be able to subscribe for any updates here