add basic networking

This commit is contained in:
2025-02-10 23:32:17 +10:00
parent 74aa8ddec4
commit 95eeab0dfe
9 changed files with 240 additions and 16 deletions

View File

@@ -14,10 +14,20 @@ const FALL_ACCELERATION: float = 25
var _respawn_point: Vector3
@onready var _camera: Camera3D = $Camera3D
@onready var _name_label: Label3D = $NameLabel
func _enter_tree() -> void:
set_multiplayer_authority(str(name).to_int())
func _ready() -> void:
_name_label.text = str(name)
if not is_multiplayer_authority():
return
_respawn_point = global_position
_camera.make_current()
func _process(_delta: float) -> void:
@@ -27,6 +37,9 @@ func _process(_delta: float) -> void:
func _physics_process(delta: float) -> void:
if not is_multiplayer_authority():
return
_lateral_movement(delta)
_vertical_movement(delta)
@@ -36,11 +49,8 @@ func _physics_process(delta: float) -> void:
func _unhandled_input(event: InputEvent) -> void:
if event is InputEventMouseMotion:
var mouse_event := event as InputEventMouseMotion
rotate_y(-mouse_event.screen_relative.x * 0.005)
_camera.rotate_x(-mouse_event.screen_relative.y * 0.005)
_camera.rotation.x = clamp(_camera.rotation.x, -PI / 2, PI / 2)
if not is_multiplayer_authority():
return
if Input.get_mouse_mode() == Input.MOUSE_MODE_CAPTURED:
if event is InputEventMouseMotion: