30 lines
1,007 B
GDScript
30 lines
1,007 B
GDScript
extends State
|
|
|
|
@export var player: Player
|
|
@export var max_speed: float = 5.0
|
|
@export var acceleration: float
|
|
@export var weapon_system: WeaponSystem
|
|
|
|
func enter() -> void:
|
|
pass
|
|
|
|
func exit() -> void:
|
|
pass
|
|
|
|
|
|
func physics_update(delta: float) -> void:
|
|
if not is_multiplayer_authority():
|
|
return
|
|
if player.is_on_floor():
|
|
transition.emit("Stand")
|
|
|
|
player.velocity += player.get_gravity() * delta
|
|
|
|
var input_dir := Input.get_vector("plr_strafe_r","plr_strafe_l", "plr_back","plr_forward")
|
|
var direction := (player.transform.basis * Vector3(input_dir.x, 0, input_dir.y)).normalized()
|
|
var modified_max_speed = max_speed * weapon_system.get_speed_modifier()
|
|
if direction:
|
|
if abs(player.velocity.x + direction.x * acceleration * delta) < abs(modified_max_speed * direction.x):
|
|
player.velocity.x += direction.x * acceleration * delta
|
|
if abs(player.velocity.y + direction.y * acceleration * delta) < abs(modified_max_speed * direction.y):
|
|
player.velocity.z += direction.z * acceleration * delta
|