Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | abelgutierrez99 |
Hello,
The idea:
1 You press right mouse button
2 While 1, if you move the mouse, the camera rotates
I tried this, but it gives an aberrant result (just the last part of the script):
func _input(event):
# keyboard inputs (xz plane movement)
if event is InputEventKey:
# forwards/backwards movement
if Input.is_action_pressed("move_backwards") and Input.is_action_pressed("move_forwards"):
pass
elif Input.is_action_pressed("move_backwards"):
translation += Vector3(0,0,self.xzSpeed)
elif Input.is_action_pressed("move_forwards"):
translation += Vector3(0, 0, -self.xzSpeed)
# right/left movement
if Input.is_action_pressed("move_left") and Input.is_action_pressed("move_right"):
pass
elif Input.is_action_pressed("move_left"):
translation += Vector3(-self.xzSpeed, 0, 0)
elif Input.is_action_pressed("move_right"):
translation += Vector3(self.xzSpeed, 0, 0)
elif event is InputEventMouseButton:
if event.is_pressed():
# zoom in
if event.button_index == BUTTON_WHEEL_UP:
fov -= self.zoomSpeed
# zoom out
if event.button_index == BUTTON_WHEEL_DOWN:
fov += self.zoomSpeed
# rotate camera
if Input.is_action_pressed("rotate_camera"):
var mouseDelta = event.position
rotation_degrees += Vector3(mouseDelta.y, -mouseDelta.x, 0)