movement system rework
This commit is contained in:
parent
900502ec8a
commit
792465a33c
7 changed files with 47 additions and 31 deletions
|
|
@ -1,7 +1,9 @@
|
|||
extends State
|
||||
|
||||
@export var player: Player
|
||||
@export var SPEED: float
|
||||
@export var max_speed: float = 5.0
|
||||
@export var acceleration: float
|
||||
@export var weapon_system: WeaponSystem
|
||||
|
||||
func enter() -> void:
|
||||
pass
|
||||
|
|
@ -20,9 +22,9 @@ func physics_update(delta: float) -> void:
|
|||
|
||||
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:
|
||||
player.velocity.x = direction.x * SPEED
|
||||
player.velocity.z = direction.z * SPEED
|
||||
else:
|
||||
player.velocity.x = move_toward(player.velocity.x, 0, SPEED)
|
||||
player.velocity.z = move_toward(player.velocity.z, 0, SPEED)
|
||||
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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue