Godot Version
4.2.1
Question
I have a player that consists of a sprite of the player himself and his gun. I want to make his gun look at the mouse. To do this, I first find the mouse position in the 3d world using this code:
func get_mouse_position_3d():
var camera = get_viewport().get_camera_3d()
var position2D = get_viewport().get_mouse_position()
var dropPlane = Plane(Vector3(0, 0, 10), 0)
var position3D = dropPlane.intersects_ray(camera.project_ray_origin(position2D),camera.project_ray_normal(position2D))
return position3D
After that, if I were making a 2d game, I would use the look_at() function, but it doesnβt work correctly with 2d sprites in the 3d world.
How do I solve this problem?