Some tweaks in the falling states
This commit is contained in:
@@ -88,8 +88,9 @@ shape = SubResource("CapsuleShape2D_tjvyk")
|
||||
cultist = NodePath("..")
|
||||
initial_state = NodePath("IdleState")
|
||||
|
||||
[node name="IdleState" parent="CultistStateMachine" unique_id=739226464 node_paths=PackedStringArray("cultist") instance=ExtResource("5_tu2pi")]
|
||||
[node name="IdleState" parent="CultistStateMachine" unique_id=739226464 node_paths=PackedStringArray("fall_state", "cultist") instance=ExtResource("5_tu2pi")]
|
||||
script = ExtResource("6_e5j7k")
|
||||
fall_state = NodePath("../FallState")
|
||||
cultist = NodePath("../..")
|
||||
|
||||
[node name="FallState" parent="CultistStateMachine" unique_id=1764777802 node_paths=PackedStringArray("look_around_state", "cultist") instance=ExtResource("5_tu2pi")]
|
||||
@@ -97,18 +98,21 @@ script = ExtResource("7_7tkj8")
|
||||
look_around_state = NodePath("../LookAroundState")
|
||||
cultist = NodePath("../..")
|
||||
|
||||
[node name="FallLeftState" parent="CultistStateMachine" unique_id=1011952297 node_paths=PackedStringArray("look_around_state", "cultist") instance=ExtResource("5_tu2pi")]
|
||||
[node name="FallLeftState" parent="CultistStateMachine" unique_id=1011952297 node_paths=PackedStringArray("fall_state", "look_around_state", "cultist") instance=ExtResource("5_tu2pi")]
|
||||
script = ExtResource("8_2opx4")
|
||||
fall_state = NodePath("../FallState")
|
||||
look_around_state = NodePath("../LookAroundState")
|
||||
cultist = NodePath("../..")
|
||||
|
||||
[node name="FallRightState" parent="CultistStateMachine" unique_id=1932915544 node_paths=PackedStringArray("look_around_state", "cultist") instance=ExtResource("5_tu2pi")]
|
||||
[node name="FallRightState" parent="CultistStateMachine" unique_id=1932915544 node_paths=PackedStringArray("fall_state", "look_around_state", "cultist") instance=ExtResource("5_tu2pi")]
|
||||
script = ExtResource("9_lu83c")
|
||||
fall_state = NodePath("../FallState")
|
||||
look_around_state = NodePath("../LookAroundState")
|
||||
cultist = NodePath("../..")
|
||||
|
||||
[node name="LookAroundState" parent="CultistStateMachine" unique_id=2025927882 node_paths=PackedStringArray("cultist") instance=ExtResource("5_tu2pi")]
|
||||
[node name="LookAroundState" parent="CultistStateMachine" unique_id=2025927882 node_paths=PackedStringArray("fall_state", "cultist") instance=ExtResource("5_tu2pi")]
|
||||
script = ExtResource("10_lu83c")
|
||||
fall_state = NodePath("../FallState")
|
||||
cultist = NodePath("../..")
|
||||
|
||||
[connection signal="animation_finished" from="CultistSprite" to="." method="_on_animation_finished"]
|
||||
|
||||
@@ -5,10 +5,5 @@ extends AbstractState
|
||||
@export var cultist: AbstractCultist
|
||||
|
||||
|
||||
func _physics_process(_delta: float) -> void:
|
||||
if !cultist.is_on_floor():
|
||||
pass
|
||||
|
||||
|
||||
func _set_ray_cast_enable(ray_cast: RayCast2D, enabled: bool) -> void:
|
||||
ray_cast.process_mode = Node.PROCESS_MODE_INHERIT if enabled else Node.PROCESS_MODE_DISABLED
|
||||
|
||||
@@ -1,5 +1,17 @@
|
||||
extends CultistFallState
|
||||
|
||||
|
||||
@export var fall_state: CultistState
|
||||
|
||||
|
||||
func enter() -> void:
|
||||
cultist.sprite.play(CultistSprite.ANIMATION_FALL_LEFT)
|
||||
|
||||
|
||||
func physics_process(delta: float) -> void:
|
||||
cultist.velocity += cultist.get_gravity() * delta
|
||||
cultist.move_and_slide()
|
||||
if cultist.is_on_floor():
|
||||
switch_state.emit(look_around_state)
|
||||
elif is_zero_approx(cultist.velocity.x):
|
||||
switch_state.emit(fall_state)
|
||||
|
||||
@@ -1,5 +1,17 @@
|
||||
extends CultistFallState
|
||||
|
||||
|
||||
@export var fall_state: CultistState
|
||||
|
||||
|
||||
func enter() -> void:
|
||||
cultist.sprite.play(CultistSprite.ANIMATION_FALL_RIGHT)
|
||||
|
||||
|
||||
func physics_process(delta: float) -> void:
|
||||
cultist.velocity += cultist.get_gravity() * delta
|
||||
cultist.move_and_slide()
|
||||
if cultist.is_on_floor():
|
||||
switch_state.emit(look_around_state)
|
||||
elif is_zero_approx(cultist.velocity.x):
|
||||
switch_state.emit(fall_state)
|
||||
|
||||
@@ -1,5 +1,13 @@
|
||||
extends CultistState
|
||||
|
||||
|
||||
@export var fall_state: CultistState
|
||||
|
||||
|
||||
func enter() -> void:
|
||||
cultist.sprite.play(CultistSprite.ANIMATION_IDLE)
|
||||
|
||||
|
||||
func physics_process(_delta: float) -> void:
|
||||
if not cultist.is_on_floor():
|
||||
switch_state.emit(fall_state)
|
||||
|
||||
@@ -1,12 +1,20 @@
|
||||
extends CultistState
|
||||
|
||||
|
||||
@export var fall_state: CultistState
|
||||
|
||||
|
||||
func enter() -> void:
|
||||
cultist.sprite.play(CultistSprite.LOOK_AROUND_ANIMATIONS.pick_random())
|
||||
_set_ray_cast_enable(cultist.left_player_close_ray, true)
|
||||
_set_ray_cast_enable(cultist.right_player_close_ray, true)
|
||||
|
||||
|
||||
func physics_process(_delta: float) -> void:
|
||||
if not cultist.is_on_floor():
|
||||
switch_state.emit(fall_state)
|
||||
|
||||
|
||||
func exit() -> void:
|
||||
_set_ray_cast_enable(cultist.left_player_close_ray, false)
|
||||
_set_ray_cast_enable(cultist.right_player_close_ray, false)
|
||||
|
||||
Reference in New Issue
Block a user