From 2a9cbb1fa0268c3be828c0d872180282704abb61 Mon Sep 17 00:00:00 2001 From: Daniel Weipert Date: Thu, 28 Dec 2023 08:48:41 +0100 Subject: show other player puppets --- Levels/Level.gd | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'Levels/Level.gd') 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 -- cgit v1.2.3