I'm trying set up a projectile to shoot at the centre of my screen but it's going in "random" directions

So im trying to get this arrow projectile so spawn in my characters hand and shoot toward the centre of my screen, where my crosshair is pointing. But it seems to be flying in seeminly random directions(sometimes they go sorta straight but that doesnt last long and isn’t accurate).

[This is what it looks like][1]

And this is the shooting function in my main character blueprint

And this is the “Arrow In Hand” position

I feel like this is one of those obvious things that I’m too much of a noobie to see, can anyone help?

I would just set the rotation based on the camera forward vector rather than tracing behind the cursor for some object that may or may not be there. Just add this vector to your projectile location, normalize, and feed that into your Look At target.

That Almost did it! thank you. However, whenever i aim at the sky the arrow just goes into the ground again

Yeah, that’s because there’s no hit result and it returns 0. Add a branch and in case of False, just use the end of the trace:

Sorry the above image I’m not entirely sure if it works or not. This one I know will work as long as your player pawn has the camera.

The crosshair and the cursor are not the same. If you set your cursor to be visible you’d see that it’s all over the place and it never stays in the center of the screen.

A standard solution would be to use Line Trace by Channel from the camera, and use its hit result to determine the target location.

1 Like

Works now, Thank you so much for your help!

You don’t actually need to trace for an object, that’s a very wasteful pattern, all you actually need is the direction of the camera to point your projectile in the right direction.

It’s third person, the rotation of the camera and the direction of the arrow are different because of the camera offset. You want your arrow to fly towards the point at which the camera is directed, not to the same direction as the camera is rotated. And the closer the target to the player, the larger the angle will be. Line trace will ensure that the arrow flies towards the target.

And I can’t really understand your setup. Normalizing a vector will return a unit vector that’s close to zero, thus it’s the point nearly at the world origin. If you use that to Find Look at Rotation, the arrow will always fly to the world origin.

Oops, yes it will fly to the origin with this setup it doesn’t need to be normalized. My point is that you could simply look in the direction of the camera’s rotation from the end of the projectile rather than tracing to the environment for some object directly in front of you.

In that case you can just use Camera Rotation, because with your setup you end up with the Camera Rotation but with extra steps. But again, that would work wrong in a third-person game.

Blue is camera forward vector, green is where the arrow should fly, red is where it will fly if you base its movement on camera forward vector alone.