Track state entry speed

This commit is contained in:
Jarrod Doyle 2024-02-26 14:53:25 +00:00
parent 78bca9eafb
commit 085118ddfa
Signed by: Jayrude
GPG Key ID: 38B57B16E7C0ADF7
2 changed files with 7 additions and 0 deletions

View File

@ -141,6 +141,7 @@ event = &"Airborne"
[node name="Falling" type="Node" parent="StateChart/Root/Airborne"]
script = ExtResource("6_8xdrw")
[connection signal="child_state_entered" from="StateChart/Root" to="." method="_on_root_child_state_entered"]
[connection signal="state_processing" from="StateChart/Root" to="." method="_on_root_state_processing"]
[connection signal="state_processing" from="StateChart/Root/Grounded/Idle" to="." method="_on_idle_state_processing"]
[connection signal="state_physics_processing" from="StateChart/Root/Grounded/Moving/Running" to="." method="_on_running_state_physics_processing"]

View File

@ -72,6 +72,8 @@ enum MovementType { VERTICAL, LATERAL }
#endregion
var target_speed := 0.0
var state_enter_speed := 0.0
var gravity := 9.8
var _velocity: Vector3 = Vector3()
var grounded_prev := false
@ -493,4 +495,8 @@ func _on_jumping_state_physics_processing(delta: float) -> void:
var target_velocity := Vector3(target_velocity_h.x, target_velocity_v, target_velocity_h.y)
move(target_velocity, delta)
func _on_root_child_state_entered() -> void:
state_enter_speed = target_speed
#endregion