24 lines
571 B
GDScript3
Raw Normal View History

2024-01-23 23:09:50 +00:00
class_name Player
extends CharacterBody3D
var client: Client
var server: Server
var cell: Vector2i
func _ready():
print("Server player spawned")
Grid.notify_cell_changed(self, cell, cell)
# var buffer := StreamPeerBuffer.new()
# buffer.put_8(Packet.STATE)
# server.broadcast(buffer.data_array)
func _physics_process(_delta):
move_and_slide()
update_grid()
func update_grid():
var new_cell := Vector2i(int(position.x / Grid.cell_size), int(position.z / Grid.cell_size))
if new_cell != cell:
Grid.notify_cell_changed(self, cell, new_cell)
cell = new_cell