Move the rest of event sending into root state
This commit is contained in:
parent
bcff3d172e
commit
eda51bcb50
|
@ -74,7 +74,8 @@ enum MovementType { VERTICAL, LATERAL }
|
||||||
var target_speed := 0.0
|
var target_speed := 0.0
|
||||||
var gravity := 9.8
|
var gravity := 9.8
|
||||||
var _velocity: Vector3 = Vector3()
|
var _velocity: Vector3 = Vector3()
|
||||||
var grounded: bool = false
|
var grounded_prev := false
|
||||||
|
var grounded := true
|
||||||
var ground_normal: Vector3
|
var ground_normal: Vector3
|
||||||
var steep_slope_normals: Array[Vector3] = []
|
var steep_slope_normals: Array[Vector3] = []
|
||||||
var total_stepped_height: float = 0
|
var total_stepped_height: float = 0
|
||||||
|
@ -448,9 +449,6 @@ func _on_falling_state_physics_processing(delta: float) -> void:
|
||||||
var target_velocity := Vector3(target_velocity_h.x, target_velocity_v, target_velocity_h.y)
|
var target_velocity := Vector3(target_velocity_h.x, target_velocity_v, target_velocity_h.y)
|
||||||
move(target_velocity, delta)
|
move(target_velocity, delta)
|
||||||
|
|
||||||
if grounded:
|
|
||||||
state_chart.send_event("Grounded")
|
|
||||||
|
|
||||||
|
|
||||||
func _on_jumping_state_physics_processing(delta: float) -> void:
|
func _on_jumping_state_physics_processing(delta: float) -> void:
|
||||||
var move_speed := run_speed
|
var move_speed := run_speed
|
||||||
|
@ -475,5 +473,8 @@ func _on_root_state_processing(_delta: float) -> void:
|
||||||
state_chart.send_event("Crouch")
|
state_chart.send_event("Crouch")
|
||||||
if Input.is_action_just_pressed("cc_jump"):
|
if Input.is_action_just_pressed("cc_jump"):
|
||||||
state_chart.send_event("Jump")
|
state_chart.send_event("Jump")
|
||||||
if !grounded:
|
|
||||||
state_chart.send_event("Airborne")
|
if grounded != grounded_prev:
|
||||||
|
var event := "Grounded" if grounded else "Airborne"
|
||||||
|
state_chart.send_event(event)
|
||||||
|
grounded_prev = grounded
|
||||||
|
|
Loading…
Reference in New Issue