I am trying to make the player look in the direction of the crosshair UI that is tweening towards the mouse’s position on the screen, however I haven’t been able to find examples of this online.
It currently only looks at the mouse position since I am using a basic script for that. I didn’t want to have the crosshair as the mouse cursor as I want the rotation of the player and the position of the cursor to be smooth rather than snappy.
I’ve seen it being done before in various games and have considered using a part that follows the mouse for the player to look at or a BodyGyro, but I want it to look exactly at the UI following the mouse.
It’s for a top-down game and the crosshair requires that the player be looking directly at it.
I think in the example you show, the player is always at the center of the screen.
So the code would see which direction (angle) the cursor is from the center of the screen, then
apply that angle to a body gyro or something to rotate the player to that direction.
There might be better ways to do this, but just thinking about it, I would create a cframe at origin, and have it look towards the position of the mouse x,y normalized, then get that roation from the created cframe.
Thanks for the response. I have some code that makes a different ImageLabel rotate in the direction of the cursor. How should I go about converting the angle of this new GUI into the rotation of the player?