I’ve just started making games in UE5, I switched from Unity. I’ve started by trying to modify the FPS Template to get a feel for how the engine works. I tried to switch the weapon from physics projectile shooting to raycasting/linetracing + impulse but the line trace returns null in certain places with very good consistency (which is kind of a bad thing).
The video button is greyed out so I guess I have to describe the code…
It finds the camera location and puts it in as the start location of the linetrace. Then it finds the rotation of the camera and gets the forward vector, multiplies it by a large number, and puts it in as the end of the linetrace. The script then preforms another linetrace that casts from the barrel of the template gun to the hit location of the first linetrace. It draws a visible line from the barrel of the gun to the hit location of the second linetrace. With the red debug line, it sometimes does not show the red square at the assumed hit location and the visible line draws from the barrel to (0,0,0).