How to prevent rotating player from "teleporting"

So I have this system that has a top-down camera and rotates the player correspondingly to where his mouse is:

As you might see, it works well. Except when you are moving the mouse directly to the other side, like so:


(Above it just an example)
The thing is, that when you do that, the player just instantly changes rotation. What I want to happen is that it rotates around to the other side, and doesn’t just “fling” there.

If you have any questions, please do feel free to ask them. Thank you for reading!

2 Likes

Instead of having the direction the model is facing track the mouse position explicitly, you could use TweenService to rotate the model to face the cursor in a certain amount of time.

This post may help to find the angle between two vectors between the position of your model and the current position of the mouse (I assume Mouse.Hit or Mouse.Hit.p by the way this code is working)

after that, the amount of time needed to rotate will be dictated by Time = Angle/DegreesPerSecond where Angle is the angle between the vectors and DegreesPerSecond is the speed it will rotate to face the mouse.

1 Like