18 lines
504 B
GDScript

extends PacketHandler
func _ready():
%PlayerAdd.main_player_spawned.connect(on_main_player_spawned)
func on_main_player_spawned(player: Player):
player.controller.jumped.connect(on_jump)
func on_jump():
var buffer := StreamPeerBuffer.new()
buffer.put_u8(PacketHandler.Packet.PLAYER_JUMP)
%Client.send(buffer.data_array)
func handle_packet(data: PackedByteArray):
var player_id := data.get_string_from_ascii()
var player := Global.players.get_player(player_id)
player.controller.jumped.emit()