diff --git a/src/playerD/Player.tscn b/src/playerD/Player.tscn index 341df42..e26bd53 100644 --- a/src/playerD/Player.tscn +++ b/src/playerD/Player.tscn @@ -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"] diff --git a/src/playerD/states/jump.gd b/src/playerD/states/jump.gd index c48c297..b4cc0d5 100644 --- a/src/playerD/states/jump.gd +++ b/src/playerD/states/jump.gd @@ -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 diff --git a/src/state_machine_animated_actor.gd b/src/state_machine_animated_actor.gd index 320e0b0..07b5009 100644 --- a/src/state_machine_animated_actor.gd +++ b/src/state_machine_animated_actor.gd @@ -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