forked from ogyrec-o/voip-3d
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathworld.gd
29 lines (25 loc) · 776 Bytes
/
world.gd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
extends Node3D
const playerScene = preload("res://character.tscn")
func _ready():
if multiplayer.is_server():
push_warning("SERVER SESSION")
multiplayer.peer_connected.connect(createPlayer)
multiplayer.peer_disconnected.connect(removePlayer)
print("CREATE SERVER %s" % 1)
var player = playerScene.instantiate()
player.name = str(1)
playersNode.add_child(player, true)
else:
push_warning("CLIENT SESSION")
pass
@onready var playersNode = $players
func createPlayer(id = 1):
print("CREATE PLAYER %s" % id)
var player = playerScene.instantiate()
player.name = str(id)
playersNode.add_child(player, true)
func removePlayer(id = 1):
print("Player remove: ", str(id))
var player = playersNode.get_node_or_null(str(id))
if player:
player.queue_free()