Let me clarify what really is the issue here. Basically i'm making a First-Person game, and i already have the camera coded and the movement and yadada, but now, i need to make the model of my player rotate to where my camera is also pointing at. Obviously he will only rotate in the X axis and not Y, but i really can't find anywhere a good way to make it work in first person. I know i could just hide the model or not show it at all in the camera, but for me, that's the approach i want to make.
Below is the code of my camera:
var gravity = 25
@onready var neck := $Neck
@onready var camera := $Neck/Camera3D
func _ready():
Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED)
func _unhandled_input(event: InputEvent):
if event is InputEventMouseButton:
Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED)
elif event.is_action_pressed("ui_cancel"):
Input.set_mouse_mode(Input.MOUSE_MODE_VISIBLE)
if Input.get_mouse_mode() == Input.MOUSE_MODE_CAPTURED:
if event is InputEventMouseMotion:
neck.rotate_y(deg_to_rad(-event.relative.x * mous_sens))
camera.rotate_x(deg_to_rad(-event.relative.y * mous_sens))
camera.rotation.x = clamp(camera.rotation.x, deg_to_rad(-40), deg_to_rad(60))
If more code is needed, it will be provided, although i do think that's not necessary. In any way, thanks to anyone that could help me with this, i really can't find it anywhere