refactor to state machine
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
extends State
|
||||
|
||||
func process_physics(delta: float) -> State:
|
||||
if not multiplayer.is_server():
|
||||
return
|
||||
|
||||
var target_velocity = Vector3(0, subject.velocity.y, 0)
|
||||
subject.velocity = subject.velocity.move_toward(target_velocity, subject.air_deceleration * delta)
|
||||
subject.velocity += Main.gravity_velocity
|
||||
subject.move_and_slide()
|
||||
|
||||
if subject.is_on_floor():
|
||||
var input_direction = %Input.direction
|
||||
if input_direction.length() < 0.05:
|
||||
return %Idle
|
||||
|
||||
if %Input.walking:
|
||||
return %Walk
|
||||
|
||||
return %Run
|
||||
|
||||
return
|
||||
Reference in New Issue
Block a user