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