Line Tracing without a camera?

I really thought it would be easier to do a line trace without a camera component, but it seems impossible. I’m trying to implement a universal weapon actor that can be added to both the player and AI. AI doesn’t have a camera actor, so I don’t want to rely on a camera for the line trace. I’ve tried a bunch of different configurations and every time the trace is just going to 0,0,0 world location and I don’t understand why. If I print string the values on tick, they’re always non-zero values so it makes no sense that the end point is becoming world zero.

I should mention that the line trace is happening inside the child bp which is simply an actor bp.

You don’t need a camera for tracing. Above, the tracing is not set up correctly.

End: Multiply Forward by distance and Add location.

If you use Get Actor Forward Vector, you will not need to cast. Although, you may need it for other reasons, ofc.

1 Like

Hey Everynone. Thanks for the post. So I did actually combine the two as I thought this was how you are supposed to handle a line trace, but it made the trace disappear entirely. I thought maybe it had something to do with the fact that I was calling the start of the trace from the socket on the child actor and the end from the parent. So I did as you suggested here, and now it’s simply shooting the line trace into the sky behind me. The really weird thing is if I undo the changes and revert to the original code I posted, which previously traced to the world origin, it now goes to the exact same position (behind and in the sky) as your suggested code. This makes literally no sense.
Here’s the new code (I used both the actor forward vector and control rot then forward vector and they both gave the same result):

And here’s a video showing the wonky location it is now tracing to:

Also, here’s a look at my character setup. So it’s just a regular character facing down the X axis with a Child Actor for the Weapon_Cannon_R which is a simple skeletal mesh facing down the X with a socket also facing down the X.

It doesn’t make sense why this isn’t working.

You’re adding GetActorForwardVector to TraceDistance. You need to multiply them like in Everynone’s picture.


Oh Eff Me. lol. This is what you get when you code while really tired :stuck_out_tongue:
Thank you so much! This solved it. ha ha.