- Edited
Hello ladies, gentlemen, and those between, I come forth today with an issue. I am making a first person shooter, and am currently trying to make the basics of the controller, which is to say I am copying everything off of the best tutorial I could find. To my dismay, there is an issue with the following code, which I have looked over and reread and copy pasted multiple times:
onready var head = $Head
onready var camera = $Head/Camera
func _ready():
#hides the cursor
Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED)
func _input(event):
#get mouse input for camera rotation
if event is InputEventMouseMotion:
rotate_y(deg2rad(-event.relative.x * mouse_sense))
head.rotate_x(deg2rad(-event.relative.y * mouse_sense))
head.rotation.x = clamp(head.rotation.x, deg2rad(-89), deg2rad(89))
Head is a child object of the player kinetic body, and Camera is a child of head. When I try to clamp the x rotation of the camera so you can't spin your head around like a bowling ball, the camera simply ignores the clamp. The reason why becomes more pronounced when I reduce the max degrees to something like 70: the camera acts as if there is a physical circle blocking the way and Leans To The Side, rotating on the z axis, to move around it. The camera is not a physics object, I am not applying forces to it, there is not a physical object it is bumping into. God, man, and nature have been defied and befuddled by this god forsaken camera. Why is it doing this.