Rotating an object towards the mouse

We are working on a 3D Sidescroller (using the sidescroller template as a base). Our character can shoot bullets from himself and the player will use the mouse to aim. Currently I am trying to rotate a spot light around the player that faces in the direction of the mouse, this will be used to help aim. I have the behavior I would like when the player is aiming on the lower half of the screen. However, once you begin to aim above the player, the spotlight begins to shine in the direction opposite the mouse, obviously not what I would like.

Here is the blueprint I am using to calculate a point in 3D space that represents the mouse location, I found this after reading through forum posts here on unrealengine.

And here is the blueprint I am using to rotate the spotlight:

Any ideas on why I am getting this behavior and how to correct it?

Of course I solved the issue nearly immediately after posting this. When getting the mouse position from ConvertMouseLocationToWorldSpace, I was projecting the mouse location into 3d, but since Unreal uses a different coordinate system, we were dividing z/z instead of x/x. Changed that and now it is working like a charm!

Hello :slight_smile:
I know you solved this long ago. But I’m working on a problem which seems similar to yours back then. In order to display the distance between two spots in the world, I need to convert my mouse location into a world location. Otherwise my result will change just by walking backwards and clicking on the same object. I think you know what I mean.

Even though i tried to copy your setup which I do not fully understand to be honest, it’s not working. It is still changing the coordinates if i click on the same place in the world when i click on it from different directions/angles

This post was a GODSEND. I’m serious. It made all my problems just vanish into thin air. I’m so happy that this post exists. Thank you so much for posting it.