Sprite Look at Mouse Location! HELP!

I was making a plataform shooter 2D game, and… What a i need to make my weapon sprite look at the mouse location?


Hey @zren! Welcome to the forums!

So what you’ll want to do is, on tick:

Get Player Controller and use that to “Convert Mouse Location to World Space.”
Use the “Location” pin. That’s your mouse coordinates.

Now drag in your weapon component and use “Set Rotation” using a “LookAt” node, with the weapon’s current Location (use Get Location) as the start and the Mouse Location as the End. :slight_smile:

If you have any issues implementing this after a good try, let us know!

Hi, I just made a system for my 2D Topdown shooter game. This is my code on the Event Tick that does the trick: 2D Aim | blueprintUE | PasteBin For Unreal Engine

It rotates the Gun Sprite and changes the rotation of the character. If you have any doubt ask. Hope it helps ^^

2D TopDown Aim Movement

1 Like