• News

• Industries

• Learning & Support

• Community

• Marketplace

# Gun line traces from center of map when not aiming at an object?

So as you can see from the images below, if i fire the guns at anywhere in the sky essentially my line trace starts from the center of the map but when i am firing anywhere at a mesh it works correctly. Does anyone have any ideas as to what this is because it’s appeared only recently having not previously done that? Many thanks.
The link to the images is below

Hi Giaus,

How are you getting the hit actor location? Mind posting a screen shot of the trace logic?

Here’s the tracelogic

It find the crosshair from the camera and then does another traceline from the end ofthe gun to the end of the first traceline ( i did this as over the shoulder close to wall the traceline would screw up as it was from the camera.

Cheers

Can’t see anything obvious from the logic

My initial thought was that the sky sphere was somehow getting hit and feeding into a trace hit/stop location. If you print the hit actor display name what shows up when it does the weird trace behavior?

Heres what it prints, a really weird amount of empty lines? performs normally on firing at an actual object

The problem is in the first line trace. If it doesn’t hit anything, the hit location will be set to 0,0,0. You should have a branch statement seeing if the first line trace hit anything. if it does, then set the hit location. If it does not hit anything, set the vector as the same endpoint you used for the first line trace. If this makes any sense at all

Okay! I will try this out in the morning thank you!

When you fire a line tracer into infinity (it hits nothing) it will return hit position 0,0,0, You multiply the hit location with 10.000 units, 10.000 times 0 is still zero.
I solved this by creating an invisible box around my level, the line tracer logic will now function properly.

Good thinking I will play around with this too thank you!

They are multiplying the forward vector of the camera by 10,000 units, not the hit location. While your solution may work, the explanation of why it will work is incorrect.

Gaius, if you are still having issues with this, let me know and I can show the blueprint when I get off of work.

Heya, still abit fuzzy, here’'s what I thought you meant linetrace tins - Album on Imgur

Close. That may work, but you want to branch from the “Return Value” from the Line Trace. What you can do is set the value to the end point right before the line trace. If the line trace return value is true, then set your “Auto Hit Location” to the hit location from the hit result. If it is false, then just go straight to the second line trace.