2024-01-26 22:45:26 +01:00

18 lines
485 B
GDScript

extends PacketHandler
func _ready():
%PlayerAdd.main_player_spawned.connect(on_main_player_spawned)
func on_main_player_spawned(player: Player):
player.jumped.connect(on_jump)
func on_jump():
var buffer := StreamPeerBuffer.new()
buffer.put_8(PacketHandler.Packet.PLAYER_JUMP)
%Client.send(buffer.data_array)
func handle_packet(data: PackedByteArray, _peer: PacketPeer):
var player_id := data.get_string_from_ascii()
var player := %Players.get_node(player_id)
player.jump()