攀爬跳跃逻辑修正
This commit is contained in:
parent
008be7a4e8
commit
8d3a3da5d5
|
|
@ -8,6 +8,6 @@ func _ready() -> void:
|
|||
#$L1_S4.switch_act_by_id(1)
|
||||
#$L1_S5.switch_act_by_id(1)
|
||||
#$L1_S6.switch_act_by_id(1)
|
||||
$L1_S7.switch_act_by_id(1)
|
||||
#$L1_S7.switch_act_by_id(1)
|
||||
|
||||
get_tree().call_group(&"PLAYER_RESPAWN",&"respawn_avatar")
|
||||
|
|
|
|||
|
|
@ -19,6 +19,8 @@ class_name Normal extends LimboHSM
|
|||
@onready var hook_shooting_state: LimboState = %HookShooting
|
||||
@onready var grapping_state: LimboState = %Grapping
|
||||
|
||||
var _climb_cd_timer: float = 0
|
||||
|
||||
func _setup() -> void:
|
||||
self._init_trans()
|
||||
self._init_handler()
|
||||
|
|
@ -39,7 +41,6 @@ func _init_trans() -> void:
|
|||
self.add_transition(ANYSTATE,on_wall_state,&"want_to_on_wall",_can_on_wall)
|
||||
self.add_transition(on_wall_state,airbone_state,&"exit_on_ground")
|
||||
self.add_transition(on_wall_state,ground_state,&"exit_on_air")
|
||||
#self.add_transition(on_wall_state,grap_hook_state,)
|
||||
|
||||
##用於處理鈎爪的State流轉
|
||||
self.add_transition(ANYSTATE,grap_hook_state,&"want_to_grap_hook",_has_move_input)
|
||||
|
|
@ -51,6 +52,10 @@ func _init_trans() -> void:
|
|||
func _update(delta: float) -> void:
|
||||
process_direction()
|
||||
|
||||
## climb状态的cd处理
|
||||
if _climb_cd_timer > 0:
|
||||
_climb_cd_timer -= delta
|
||||
|
||||
##如果玩家当前在墙上,并且玩家按下了climb
|
||||
if agent.wall_detector.is_on_wall and agent.m_climb_press:
|
||||
self.dispatch(&"want_to_on_wall")
|
||||
|
|
@ -96,5 +101,9 @@ func _get_dash_exit_enter_state()->LimboState:
|
|||
func _has_move_input() -> bool:
|
||||
return agent.get_move_input() != Vector2.ZERO
|
||||
|
||||
func _trigger_climb_cd(duration: float) -> void:
|
||||
if duration > 0:
|
||||
_climb_cd_timer = duration
|
||||
|
||||
func _can_on_wall() -> bool:
|
||||
return not grap_hook_state.is_active()
|
||||
return not grap_hook_state.is_active() and _climb_cd_timer <= 0
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@ 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()
|
||||
|
|
@ -27,8 +28,13 @@ func _handler_climb_state_finished() -> bool:
|
|||
|
||||
func _handler_trigger_jump() -> bool:
|
||||
if self.get_active_state() == root.climb_state:
|
||||
var input_x: float = agent.m_input_intent_direction.x
|
||||
var wall_dir: float = agent.get_wall_normal().x
|
||||
if sign(input_x) * sign(wall_dir) > 0:
|
||||
root._trigger_climb_cd(.12)
|
||||
self.get_root().blackboard.set_var(&"want_to_jump",true)
|
||||
_handler_climb_state_finished()
|
||||
return true
|
||||
|
||||
self.dispatch(&"want_to_climb_jump")
|
||||
return true
|
||||
|
||||
func _handler_climb_jump_state_finished() -> bool:
|
||||
return true
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue