godot-third-person-basic-scene/camera.gd
2022-01-20 14:59:59 +01:00

16 lines
494 B
GDScript

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
get_viewport().warp_mouse(starting_point)
func _input(event):
# If right mouse button is pressed and mouse moves, pan horizontally camera
if Input.is_mouse_button_pressed( 2 ):
if event is InputEventMouseMotion:
$horizontal_root.rotate_y( event.relative.x *0.01 )