32 lines
1020 B
GDScript
32 lines
1020 B
GDScript
extends LimboState
|
|
|
|
func _setup() -> void:
|
|
self.add_event_handler(&"completed_climb",_handler_completed_climb)
|
|
|
|
func _enter() -> void:
|
|
agent.locomotion_comp.suspend_movement()
|
|
agent.locomotion_comp.stop_dash(true)
|
|
agent.locomotion_comp.start_climb(true)
|
|
|
|
get_root().blackboard.set_var(&"lock_direction_changed",true)
|
|
|
|
func _exit() -> void:
|
|
agent.locomotion_comp.enable_movement()
|
|
agent.locomotion_comp.suspend_climb()
|
|
|
|
get_root().blackboard.set_var(&"lock_direction_changed",false)
|
|
print("离开攀爬")
|
|
|
|
func _update(delta: float) -> void:
|
|
var climb_dir = Input.get_axis("move_up","move_down") as float
|
|
agent.locomotion_comp.add_climb_input(climb_dir)
|
|
|
|
var _enter_climb_hop = not agent.wall_detector.up_ray_on_wall and not agent.wall_detector.mid_ray_on_wall and agent.wall_detector.down_ray_on_wall and climb_dir< 0
|
|
if _enter_climb_hop:
|
|
agent.locomotion_comp.climb_hop()
|
|
self.dispatch(self.EVENT_FINISHED)
|
|
|
|
func _handler_completed_climb() -> bool:
|
|
self.dispatch(self.EVENT_FINISHED)
|
|
return true
|