Split client and server

This commit is contained in:
2024-01-24 00:09:50 +01:00
parent 532a1faa21
commit 26c52a00b3
59 changed files with 335 additions and 142 deletions

View File

@ -0,0 +1,44 @@
class_name Character
extends CharacterBody3D
@export var model: Node3D
@export var move_speed: float = 4.5
@export var rotation_speed: float = 20.0
const JUMP_VELOCITY := 4.5
const DECELERATE := 0.75
var direction: Vector3
var angle: float
var gravity: float = ProjectSettings.get_setting("physics/3d/default_gravity")
func _process(delta):
if direction:
angle = atan2(direction.x, direction.z)
model.rotation.y = lerp_angle(model.rotation.y, angle, rotation_speed * delta)
func _physics_process(delta):
if direction:
velocity.x = direction.x * move_speed
velocity.z = direction.z * move_speed
else:
velocity.x *= DECELERATE
velocity.z *= DECELERATE
if !is_on_floor():
velocity.y -= gravity * delta
move_and_slide()
func jump():
if !is_on_floor():
return
velocity.y = JUMP_VELOCITY
func dash():
print("dash")
func attack():
print("attack")