How do you get projectiles to shoot at cursor location?

I am currently working on a top down pixel art game and I’m trying to get the projectiles I am using to aim at the mouse position. All the tutorials I’ve found are pretty old and suggest using the ‘get hit result under cursor channel’ blueprint which I can’t find it.


I am posting the code I’ve been using. The mouse definitely has some impact on the rotation however, its incredibly inaccurate. If you’re wondering why I’m adding/subtracting or multiplying/dividing random things its because I’m trying to center everything and make the positions use the same scale. I’m assuming my code is completely wrong but I don’t know what else to do.

‘get hit result under cursor channel’ blueprint which I can’t find it.

Drag a wire and search:

You can do it with the above, or:

This would give you the location of the cursor projected into the world above the ground - at the player’s waist, lets say. Now, depending on how the projectiles are supposed to work, you may need either direction or magnitude:

  • in the projectile:

  • so we can fire it like so:

Ensure the projectiles do not collide with the player (collision settings of the root component / static mesh in the projectile actor). We don’t want to shoot ourselves in the foot.

Hope it helps.

Thanks for your reply. I feel like a total dumbass right now because I didn’t realize you just had to drag off the node from get player controller to find the blueprint. This was extremely helpful though thanks so much!

1 Like

hi
is there a way that my cursor stays in a limited radius around the character? i want it to be fixed, so it doesnt move much away than that limited radius, somewhat in a way that " The Ascent’’ crosshair is

I wouln’t limit the cursor - it may lead to undesirable behaviours. Let it be but hide it, and just draw a 2d marker that imitates it.

Get unit direction, multiply it by distance, clamp it. Draw a fake cursor marker there.

1 Like

How would I go about replicating this for clients without the jittering?

is there any advice to make this work replicated? I’m writting server logic in controller which is controlling a pawn that tells a server character where to be and so the get player controller isnt working for me