godot-plateformer/_player/states/on_wall.gd

35 lines
1018 B
GDScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

extends LimboHSM
@onready var root: Normal = %Normal
func _setup() -> void:
self.add_event_handler(&"trigger_jump",_handler_trigger_jump)
self.add_event_handler(root.climb_state.EVENT_FINISHED,_handler_climb_state_finished)
self.add_event_handler(root.climb_jump_state.EVENT_FINISHED,_handler_climb_state_finished)
self.add_transition(root.climb_state,root.climb_jump_state,&"want_to_climb_jump")
func _enter() -> void:
if agent.is_on_wall():##如果已经在Wall上则什么都不做
return
var compensaton_velocity = Player.get_direction_vector(agent.direction) * 1000
agent.velocity = compensaton_velocity
agent.move_and_slide()
func _handler_climb_state_finished() -> bool:
if agent.is_on_floor():
self.dispatch(&"exit_on_ground")
else:
self.dispatch(&"exit_on_air")
return true
func _handler_trigger_jump() -> bool:
if self.get_active_state() == root.climb_state:
self.dispatch(&"want_to_climb_jump")
return true
func _handler_climb_jump_state_finished() -> bool:
return true