27 lines
804 B
GDScript
27 lines
804 B
GDScript
extends Node3D
|
|
|
|
## NS-16: composes ground pick + server authority; see `ground_pick.gd` /
|
|
## `position_authority_client.gd`.
|
|
|
|
@onready var _camera: Camera3D = $World/Camera3D
|
|
@onready var _player: CharacterBody3D = $Player
|
|
@onready var _ground_pick: Node3D = $GroundPick
|
|
@onready var _authority: Node = $PositionAuthorityClient
|
|
|
|
|
|
func _ready() -> void:
|
|
_ground_pick.set("fallback_camera", _camera)
|
|
_ground_pick.connect("target_chosen", Callable(self, "_on_target_chosen"))
|
|
_authority.connect(
|
|
"authoritative_position_received", Callable(self, "_on_authoritative_position")
|
|
)
|
|
_authority.call("sync_from_server")
|
|
|
|
|
|
func _on_target_chosen(world: Vector3) -> void:
|
|
_authority.call("submit_move_target", world)
|
|
|
|
|
|
func _on_authoritative_position(world: Vector3) -> void:
|
|
_player.snap_to_server(world)
|