Jump can now clear out a lingering fall animation transition.

This commit is contained in:
Nitsud Yarg 2024-06-19 23:00:25 -07:00
parent eb47082730
commit 0686e8e8b0
3 changed files with 12 additions and 2 deletions

View File

@ -516,6 +516,7 @@ animation_sequence = [ "jump" ]
idle_node = NodePath("../idle")
fall_node = NodePath("../fall")
attack_node = NodePath("../attack")
landing_node = NodePath("../fall/landing")
jump_force = 250.0
[node name="attack" type="Node" parent="movement_state_machine" index="4"]

View File

@ -4,15 +4,22 @@ extends StateAnimatedActor
export (NodePath) var idle_node
export (NodePath) var fall_node
export (NodePath) var attack_node
export (NodePath) var landing_node
onready var idle_state: State = get_node(idle_node)
onready var fall_state: State = get_node(fall_node)
onready var attack_state: State = get_node(attack_node)
onready var landing_mod: StateModifier = get_node(landing_node)
export var jump_force: float = 200.0
func enter() -> void:
var landing_mod_index = modifier_stack_ref.rfind(landing_mod)
if landing_mod_index != -1:
#print("You're Supposed to be dead!?: ", landing_mod_index)
modifier_stack_ref.remove(landing_mod_index)
# if modifier_stack_ref.has(landing_mod):
# print("Jump from Landing Mod at: ", modifier_stack_ref.rfind(landing_mod))
.enter()
if previous_speed_multiplier > 1.0:
speed_multiplier = previous_speed_multiplier

View File

@ -15,7 +15,9 @@ func change_state(new_state: State) -> void:
print(mods.name)
func set_previous_animation( old_state: StateAnimatedActor, new_state: StateAnimatedActor ) -> void:
new_state.previous_animation_name = old_state.mod_animation_sequence[old_state.current_animation_sequence]
# added this to help prevent nul index crashes. (Usually because of signal based state changes.)
if old_state.mod_animation_sequence:
new_state.previous_animation_name = old_state.mod_animation_sequence[old_state.current_animation_sequence]
new_state.previous_state_frame_number = old_state.animations.frame
new_state.previous_state_name = old_state.name
new_state.previous_speed_multiplier = old_state.speed_multiplier