29 lines
752 B
GDScript
29 lines
752 B
GDScript
extends CharacterBody3D
|
|
class_name ServerNode
|
|
|
|
var jumping := false
|
|
var input_direction: Vector2 = null
|
|
var owner_id: int = 0
|
|
|
|
func _ready() -> void:
|
|
pass
|
|
|
|
func _physics_process(delta: float) -> void:
|
|
if not is_on_floor():
|
|
velocity += get_gravity() * delta
|
|
if is_on_floor() && jumping:
|
|
velocity.y = const .
|
|
|
|
#if shooting:
|
|
jumping = false
|
|
|
|
var direction := (transform.basis * Vector3(input_direction.x, 0, input_direction.y)).normalized()
|
|
if is_on_floor():
|
|
if direction:
|
|
#first_view_legs_anim.play("Run Forward")
|
|
velocity.x = direction.x * character_speed
|
|
velocity.z = direction.z * character_speed
|
|
else:
|
|
velocity.x = move_toward(velocity.x, 0, character_speed)
|
|
velocity.z = move_toward(velocity.z, 0, character_speed)
|