Godot 3d top down movement causes unexpected rotation

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By seanc

Video preview of the bug I’m facing →

Project source code

I am prototyping some top-down movement and tried implementing movement similar to Battlerite. Player movment with w a s d and rotating the character with the mouse–very traditional top-down movement controls.

The problem I am facing is when I am moving my character around it is rotating the character, even when I am not moving the mouse at all.

You can see in the video preview I provided at the top of this post that the mouse position does not move at all. I did some troubleshooting and somehow calling look_at while moving the character. If I comment out look_at there is no more rotating.

So my real question is: Is there a way to stop character rotation while only moving in my implementation? I only want mouse movement to control how much the character rotates.

My look_at-related code:

var drop_plane = Plane(Vector3.UP, player_bottom.global_transform.origin.y)

var ray_length = 1000
var mouse_position = get_viewport().get_mouse_position()
var from = camera.project_ray_origin(mouse_position)
var to = from + camera.project_ray_normal(mouse_position) * ray_length

var distance = Vector3.ZERO
distance.y = player_bottom.transform.origin.distance_to(body.transform.origin)

var intersects_at = drop_plane.intersects_ray(from, to)
var cursor_pos = Vector3()
if intersects_at:
  cursor_pos = intersects_at + distance

body.look_at(cursor_pos, Vector3.UP)
body.rotation = body.rotation * Vector3.UP
1 Like
:bust_in_silhouette: Reply From: seanc

Changing the following line corrects the problem!

var to = from + camera.project_ray_normal(mouse_position) * ray_length

to this:

var to = camera.project_ray_normal(mouse_position) * ray_length
# I just got rid of "from +"
2 Likes

Came across this post on the 6th of December, 2025 and just wanted to give my thanks to whoever made it. This problem stumped me for hours and getting rid of the “from +” fixed it!