Proper swap, generic mouse confinment and win
This commit is contained in:
parent
cba43ee477
commit
5df5633c27
16 changed files with 136 additions and 96 deletions
|
|
@ -14,7 +14,7 @@ func _ready() -> void:
|
|||
if not is_multiplayer_authority():
|
||||
return
|
||||
# Move to level controller when possible
|
||||
Input.mouse_mode = Input.MOUSE_MODE_CAPTURED
|
||||
MouseConfiner.set_global_mode(Input.MOUSE_MODE_CAPTURED)
|
||||
current = true
|
||||
|
||||
func _process(delta: float) -> void:
|
||||
|
|
|
|||
37
players/spectator.gd
Normal file
37
players/spectator.gd
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
extends Camera3D
|
||||
|
||||
@export var SPEED = 10.0
|
||||
|
||||
func _enter_tree() -> void:
|
||||
set_multiplayer_authority(int(name))
|
||||
|
||||
func _ready() -> void:
|
||||
if not is_multiplayer_authority():
|
||||
return
|
||||
# Move to level controller when possible
|
||||
MouseConfiner.set_global_mode(Input.MOUSE_MODE_CAPTURED)
|
||||
current = true
|
||||
|
||||
func _process(delta: float) -> void:
|
||||
if not is_multiplayer_authority():
|
||||
return
|
||||
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 not is_multiplayer_authority():
|
||||
return
|
||||
if event is InputEventMouseMotion:
|
||||
rotate_camera(-event.relative.x * ClientSettings.SENSITIVITY,-event.relative.y * ClientSettings.SENSITIVITY)
|
||||
|
||||
@rpc("any_peer","call_local","reliable")
|
||||
func set_after_spawn(start_position: Vector3, _team: int):
|
||||
global_position = start_position
|
||||
1
players/spectator.gd.uid
Normal file
1
players/spectator.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://cikw7fcykkpd5
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
[gd_scene load_steps=2 format=3 uid="uid://ckjabjcvgki6n"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://cikw7fcykkpd5" path="res://spectator.gd" id="1_jjbhc"]
|
||||
[ext_resource type="Script" uid="uid://cikw7fcykkpd5" path="res://players/spectator.gd" id="1_jjbhc"]
|
||||
|
||||
[node name="Spectator" type="Camera3D"]
|
||||
transform = Transform3D(-1, 0, -8.742278e-08, 0, 1, 0, 8.742278e-08, 0, -1, 0, 0, 0)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue