Godot Version
4.5.1
Question
I’m making a fnaflike game in godot, I want the camera to rotate whenever the mouse’s x position is higher than a certain amount, or lower than a certain amount, this on it’s own works fine, but when the mouse isn’t moving absolutely nothing happens, the mouse rotating the camera is fine as is, but it just refuses to do so whenever the mouse position isn’t updating.
code is below.
var mousepos = get_viewport().get_mouse_position().x
var mousex = mousepos
var inmiddle = 0
var camy = neck.rotation.y
#print(mousex)
#print(mousey)
@warning_ignore("integer_division")
if mousex > (gameWidth/3) and mousex < ((gameWidth/3)*2):
#print("middle")
inmiddle = 1
neck.rotation = Vector3(0,camy,0)
else:
inmiddle = 0
@warning_ignore("integer_division")
if inmiddle == 0 and mousex > (gameWidth/2):
#print("turnright")
neck.rotation.y -= deg_to_rad(2)
@warning_ignore("integer_division")
if inmiddle == 0 and mousex < (gameWidth/2):
#print("turnleft")
neck.rotation.y += deg_to_rad(2)