46 lines
1.3 KiB
GDScript
46 lines
1.3 KiB
GDScript
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()
|
|
# Apply initial jump velocity on state enter
|
|
move_component.velocity.y = -jump_force
|
|
|
|
func process_physics(delta: float) -> State:
|
|
|
|
if move_component.velocity.y > 0:
|
|
return fall_state
|
|
|
|
if move_component.wants_shoot():
|
|
return attack_state
|
|
|
|
# First allow horizontal movement.
|
|
move_actor_as_desired(delta)
|
|
|
|
#Flip the character before tha actual move maybe.
|
|
if move_component.get_movement_direction() != 0.0:
|
|
parent.transform.x.x = move_component.get_movement_direction()
|
|
|
|
if parent.is_on_floor():
|
|
return idle_state
|
|
|
|
return null
|