From 7b0dc049213f34bbab0a2f74f1ce7decc392c2a3 Mon Sep 17 00:00:00 2001 From: yannk Date: Thu, 20 Jan 2022 15:04:58 +0100 Subject: [PATCH] Adding vertical rotation to camera --- camera.gd | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/camera.gd b/camera.gd index d5398d7..2e8e7bb 100644 --- a/camera.gd +++ b/camera.gd @@ -1,15 +1,16 @@ extends Node3D -var camera_rotation_horizontal = 0 var starting_point = Vector2(DisplayServer.window_get_size().x / 2, DisplayServer.window_get_size().y / 2) func _ready(): -# Place the mouse à the center of the screen +# Place the mouse at the center of the screen get_viewport().warp_mouse(starting_point) func _input(event): # If right mouse button is pressed and mouse moves, pan horizontally camera + # and rotate vertically if Input.is_mouse_button_pressed( 2 ): if event is InputEventMouseMotion: $horizontal_root.rotate_y( event.relative.x *0.01 ) + $horizontal_root/vertical_root.rotate_x( event.relative.y * 0.01 )