Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | ioio |
Hi, i managed to get the position of the mouse in 3d and i want to rotate the Y axis of the player to that position, but i dont know how to get that angle. This is how i get the mouse position:
func _input(event):
if event is InputEventMouseMotion:
var state = get_world().direct_space_state
var camera = $Camera
var from = camera.project_ray_origin(event.position)
var to = from + camera.project_ray_normal(event.position) *50
var ray_result = state.intersect_ray(from, to,[self])
if ray_result:
var p= ray_result["position"]
The game is like a top-down-shooter and the camera is not a child of the player or it will rotate with him and mess up the mouse position.
If I get that right you’re trying to rotate something along the y-axis, said rotation being dictated by the movements of the mouse ?
TheFamousRat | 2019-02-17 23:47