Split client and server
This commit is contained in:
44
client/character/Character.gd
Normal file
44
client/character/Character.gd
Normal 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")
|
Reference in New Issue
Block a user