I've been trying to make a top-down game where the character faces towards the position of the mouse. I searched online and I figured out I have to use raycasting. More specifically, I implemented the following code:
if event is InputEventMouseMotion:
var from = camera.project_ray_origin(event.position)
var to = from + camera.project_ray_normal(event.position) * ray_length
where player is the character in question and raylength is the distance travelled by the ray. It is worth noting that 'player' is a separate scene made up of a KinematicBody and a mesh.
Though everything works as expected when the player is in the middle, everything starts malfunctioning when I move the player using moveand_slide(). This is when the object stops rotating fully in a circle.
What am I doing wrong?