Split client and server
This commit is contained in:
24
server/player/Player.gd
Normal file
24
server/player/Player.gd
Normal file
@ -0,0 +1,24 @@
|
||||
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
|
14
server/player/Player.tscn
Normal file
14
server/player/Player.tscn
Normal file
@ -0,0 +1,14 @@
|
||||
[gd_scene load_steps=3 format=3 uid="uid://148x2hp1hjq0"]
|
||||
|
||||
[ext_resource type="Script" path="res://player/Player.gd" id="1_46xlc"]
|
||||
|
||||
[sub_resource type="CapsuleShape3D" id="CapsuleShape3D_y8kaq"]
|
||||
radius = 0.25
|
||||
height = 1.6
|
||||
|
||||
[node name="Player" type="CharacterBody3D"]
|
||||
script = ExtResource("1_46xlc")
|
||||
|
||||
[node name="Collision" type="CollisionShape3D" parent="."]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.8, 0)
|
||||
shape = SubResource("CapsuleShape3D_y8kaq")
|
Reference in New Issue
Block a user