Make character rotate towards mouse in top down camera like agario

I am making a game similar to agar.io, and I already have the part of the movement system that actually makes the character move towards the mouse, but I cant find a way to make the character rotate in the same direction it is moving. How would I go about doing this?

1 Like
--where a and b are Vector2's, a is the character coords and b is the mouse ones
local rotation = math.deg(math.atan2(b.Y-a.Y, b.X-a.X))
print(rotation) --you can use this to rotate a UI through the Rotation property

A BodyGyro should be all you need to handle the rotation of the character. Alternatively, you could do the math for the CFrame to update every frame but that is unecessary extra work imo. Roblox documentation recommends using AlignOrientation as BodyGyro has been deprecated, however you may notice that BodyGyro is a little simpler.

it’s a 3d game with a top down perspective

For your situation, the Z is the Y. Although since it’s a 3d one you may want to check the above reply.