[UMG] 2D texture at mouse position rotate towards target

Greetings! I hope my thread title isn’t too confusing to establish what I’m trying to do.

626f05ca451673578f3fa4b447cd4b6eaad4d098.jpeg

I have this texture that I position on screen at the player’s mouse coordinates. Essentially wherever the mouse pointer goes, this texture goes with it.

What I am aiming to do is get the screen position of the mouse as well as convert the world space vector of an actor to screen space and rotate the texture so that the arrow points towards the location of the ‘target’ actor.

I have blueprints in place to ‘select’ an actor by clicking on it, and I have the location vector data stored in a variable, I just need some help with the appropriate blueprint nodes and maths work to put it all together.

An example of what I’m looking for comes from Hostile Waters. I’ll put a couple of images below to demonstrate.

8b313c7b434a12418eb787bdaae6091a4111bf2a.jpeg
Clipboard04.jpg

The two images above show that when the mouse is either above or below (also works for left/right) the target the arrow around the mouse cursor will rotate to always face towards the target.

Hopefully someone out there can point me in the right direction!

In the following image you can see how I would start trying this. Of course you will only need 1 value of the resulting Rotator. Depending on which direction your unrotated texture is pointing at you will need to add a multiple of 90 to the result. I might be missing something but I don’t know why something like this wouldn’t work.

That did the trick! Thank you very much. :smiley:

There is a small issue. When the target actor is not on screen, the “project world to screen” results start to get out of whack a little. It works fine until the player is facing maybe 95-100 degrees away from the target, that’s when the X and Y results of the screen projection bounce up to something like ‘900000 X / 38000 Y’ and the rotation calculation just decides to go on smoko haha. Is there something that can be done about that?