How do I rotate my player with the direction of my camera?

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

I have this function

 func _input(event):
	if event is InputEventMouseMotion:
		head.rotate_y(deg2rad(-event.relative.x* mouse_sens))
		var x_delta = event.relative.y * mouse_sens
		if camera_x_rotation + x_delta > -90 and camera_x_rotation + x_delta < 90:
			camera.rotate_x(deg2rad(-x_delta))
			camera_x_rotation+= x_delta

it works but my player mesh doesnt rotate with it, just the camera is rotating around and the mesh is static. How can I get the player to rotate with it so that when I attach a weapon to my FPS player the gun will move with the camera im facing rather than the head just moving itself.

Maybe make the player mesh child of the head

nafysbrhm | 2020-09-02 05:46