2024-05-25 17:15:59 -06:00
|
|
|
extends MultiplayerSpawner
|
|
|
|
|
|
|
|
func _ready():
|
|
|
|
set_multiplayer_authority(1)
|
|
|
|
spawn_function = spawn_player
|
|
|
|
|
|
|
|
func spawn_player(owner_id: int):
|
|
|
|
var player := preload("res://player/player.tscn").instantiate()
|
2024-05-31 21:59:49 -06:00
|
|
|
player.name = str(owner_id)
|
2024-05-25 17:15:59 -06:00
|
|
|
player.set_multiplayer_authority(owner_id)
|
|
|
|
if multiplayer.get_unique_id() == owner_id:
|
|
|
|
var camera := preload("res://camera/camera.tscn").instantiate()
|
|
|
|
player.add_child(camera)
|
|
|
|
return player
|
|
|
|
|
2024-05-31 21:59:49 -06:00
|
|
|
func despawn_player(owner_id: int):
|
2024-06-03 11:05:52 -06:00
|
|
|
var node := get_node(spawn_path).get_node(str(owner_id))
|
|
|
|
node.queue_free()
|
|
|
|
await node.tree_exited
|