I’m having some issues getting a handle to rotate with the player mouse acting as the driving force. ( think Amnesia) when interacting with the handle the player need to move the mouse in a circle which drives the rotation and rotates the handle. ( as if they are turning it).
I currently am creating a circle when you interact with the handle abs then normalising the output of where the mouse is but this is not working. Any ideas would be much appreciated!
I think “viewport” and “screen” coordinates may actually be different, at least when using “cinematic camera” or letterboxing, so that might be something to watch out for.
It takes a position in X and Y, in math-style coordinates (X to the right, Y upwards on a piece of paper) and returns the angle from the origin to that point. (Obviously it doesn’t work when the X and Y values are exactly 0,0 !)
(Also, oops, in the picture I wired X to Y and Y to X, which will return the degrees rotating the other way … feel free to wire it up correctly when you use it )
A reasonable description can be found here:
The wikipedia page on the function is … complete, but not beginner friendly…
It finds the look at rotation from the mouse position to the center of the screen (or any Vector2).
Like i said, i haven’t tried it in action, but it gets a 0 to 180 and -180 to -0 rotation. So it seems like it can be used.