Spectator
This commit is contained in:
parent
787de0ab09
commit
938feb9b35
5 changed files with 38 additions and 0 deletions
20
scripts/player/spectator.gd
Normal file
20
scripts/player/spectator.gd
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
extends Camera3D
|
||||
|
||||
@export var SENSITIVITY = 0.02
|
||||
@export var SPEED = 10.0
|
||||
|
||||
func _process(delta: float) -> void:
|
||||
var xz_plane = Input.get_vector("plr_strafe_l","plr_strafe_r","plr_forward","plr_back")
|
||||
var y = Input.get_axis("spc_down","spc_up")
|
||||
|
||||
var direction = Vector3(xz_plane.x,y,xz_plane.y)
|
||||
global_position += global_basis * direction * SPEED * delta
|
||||
|
||||
func rotate_camera(x,y) -> void:
|
||||
rotate_y(x)
|
||||
rotation.x = clamp(rotation.x + y,-PI/2,PI/2)
|
||||
orthonormalize()
|
||||
|
||||
func _input(event: InputEvent) -> void:
|
||||
if event is InputEventMouseMotion:
|
||||
rotate_camera(-event.relative.x * SENSITIVITY,-event.relative.y * SENSITIVITY)
|
||||
1
scripts/player/spectator.gd.uid
Normal file
1
scripts/player/spectator.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://cikw7fcykkpd5
|
||||
Loading…
Add table
Add a link
Reference in a new issue