summaryrefslogtreecommitdiff
path: root/Levels
diff options
context:
space:
mode:
Diffstat (limited to 'Levels')
-rw-r--r--Levels/Level.gd19
1 files changed, 19 insertions, 0 deletions
diff --git a/Levels/Level.gd b/Levels/Level.gd
index 910feb8..17975ef 100644
--- a/Levels/Level.gd
+++ b/Levels/Level.gd
@@ -19,6 +19,25 @@ func _ready():
character = load("res://Characters/" + Network.player.character + ".tscn").instantiate()
self.set_player(character)
+ Network.connect("player_changed", func(id):
+ var remote_player = Network.players[id]
+ var node_name = "%s_%s_%s" % [remote_player.name, remote_player.character, id]
+ var puppet = self.get_node(node_name)
+
+ if remote_player.current_level != self.idx:
+ if puppet:
+ puppet.queue_free()
+ return
+
+ if not puppet:
+ puppet = load("res://Characters/" + remote_player.character + ".tscn").instantiate()
+ puppet.process_mode = PROCESS_MODE_DISABLED
+ self.add_child(puppet)
+ puppet.name = node_name
+ else:
+ puppet.position = remote_player.position
+ )
+
if has_node("ParallaxBackground"):
$ParallaxBackground/ParallaxLayer.motion_mirroring.x = (
$ParallaxBackground/ParallaxLayer/Sprite2D.get_rect().size