15 lines
393 B
GDScript
15 lines
393 B
GDScript
extends KinematicBody
|
|
|
|
var mouse_sensitivity = 0.03
|
|
|
|
onready var head = $Head
|
|
|
|
func _ready():
|
|
Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED)
|
|
|
|
func _input(event):
|
|
if event is InputEventMouseMotion:
|
|
rotate_y(deg2rad(-event.relative.x * mouse_sensitivity))
|
|
head.rotate_x(deg2rad(-event.relative.y * mouse_sensitivity))
|
|
head.rotation.x = clamp(head.rotation.x, deg2rad(-89), deg2rad(89))
|