Fix exiting crouch state after dodging

This commit is contained in:
TheThomaas 2026-10-12 09:43:47 +02:00
parent eb6432e7a0
commit 0398ac3345

View file

@ -11,10 +11,21 @@ var play_char : CharacterBody3D
var dodge_dir : Vector2 = Vector2.ZERO
var dodge_timer : float = 0.0
var dodge_duration_ref : float = 0.0
var came_from_crouch : bool = false #true si l'esquive vient du crouch (directement, ou via Aim declenche depuis le crouch)
func enter(play_char_ref : CharacterBody3D) -> void:
play_char = play_char_ref
#curr_state_name n'est pas encore mis a jour a ce stade : il reflete encore l'etat qu'on quitte
var previous : String = play_char.state_machine.curr_state_name
if previous == "Crouch":
came_from_crouch = true
elif previous == "Aim":
var aim : Node = play_char.state_machine.states.get("aimstate")
came_from_crouch = aim != null and aim.came_from_crouch
else:
came_from_crouch = false
verifications()
func verifications() -> void:
@ -69,7 +80,12 @@ func end_dodge() -> void:
if !play_char.is_on_floor():
transitioned.emit(self, "InairState")
elif Input.is_action_pressed(play_char.aim_cam_action):
#AimState ne verra que "Dodge" comme etat precedent : on lui transmet l'origine crouch
var aim : Node = play_char.state_machine.states.get("aimstate")
if aim: aim.came_from_crouch = came_from_crouch
transitioned.emit(self, "AimState") #le joueur a garde la visee enfoncee pendant la roulade
elif came_from_crouch:
transitioned.emit(self, "CrouchState")
elif play_char.move_dir:
transitioned.emit(self, play_char.walk_or_run)
else: