diff options
author | Daniel Weipert <git@mail.dweipert.de> | 2023-12-28 08:48:41 +0100 |
---|---|---|
committer | Daniel Weipert <git@mail.dweipert.de> | 2023-12-28 08:48:41 +0100 |
commit | 2a9cbb1fa0268c3be828c0d872180282704abb61 (patch) | |
tree | 4d2a9f805af004a7b960e7918b5d34ddfed7f2c8 /Levels | |
parent | 2a5d745c68f11131fb1b27ec42a30ecd6dc5da1d (diff) |
show other player puppetsv2.2.0
Diffstat (limited to 'Levels')
-rw-r--r-- | Levels/Level.gd | 19 |
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 |