Trying to get a linetrace going from a sphere object infront of the camera. It’s supposed to go out straight forward from the camera but appears to go down diagonally and to the left.
(Sphere is there to better demonstrate the problem, will have trace running from the camera eventually)
I’m taking the world rotation and position of the sphere and then adding 100 to the start pos to get the end of my trace. The nodes after the linetrace are just debugging / identifying what’s traced.
Try the following:
-Your start position is just fine. Don’t don’t anything to it.
-Disconnect “Sphere” from your second Get World Rotation that you connected to Get Forward Vector.
-Connect the Camera component instead.
I use this to get a ray trace in the direction the camera is looking in my own personal project.
Can you try this blueprint exactly as is and see if it at least fixes the direction?
Th trace will not start at the sphere but at the camera. I just want to see if it fixes the directional issue first.
Also, can I get a screenshot of the sphere selected in the viewport of your player character blueprint?
In your BP, right when you should scale the forward vector you are doing subtraction instead of multiply. In the picture haruna posted, there is a proper multiplication and his version will work. Also, multiplying by only 100 UU means the trace will be a very short one (forward vector is a normalized vector). I usually place the trace length as a variable and then tweak it (I often end up having it into thousands, but that depends on the actual intended use).
For future: It’s much easier to actually do the script the way you want it finally (means from camera) and then use “toggledebugcamera” console command to see where the debug line trace was actually drawn rather than messing this way. Tracing to camera means you have the line very very close to nearZ and yourself, which means that even a simple float precision error will seem like a huge offset (and even a proper line may show up angled from such perspective).
Alternatively, use something that has easily visible rotation (Arrow component or some non-symmetrical mesh), because it’s impossible to say if you haven’t actually rotated the sphere the way it’s tracing.