Player movement rework
This commit is contained in:
parent
b601b9430e
commit
7bbeebdd2e
11 changed files with 190 additions and 73 deletions
28
scripts/player/states/falling.gd
Normal file
28
scripts/player/states/falling.gd
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
extends State
|
||||
|
||||
@export var player: Player
|
||||
@export var SPEED: float
|
||||
|
||||
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()
|
||||
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)
|
||||
Loading…
Add table
Add a link
Reference in a new issue