commit 8e7da96bfcd52b230feaf40fbc6d4a42b80c5723
Author: TheThomaas <thethomaas@protonmail.ch>
Date: Sat Oct 17 18:55:14 2026 +0200
Make state machine more reusable
commit 37da7248b8c33ce95cff7ef9332c5ccf6e3cd418
Author: TheThomaas <thethomaas@protonmail.ch>
Date: Sat Oct 17 18:44:34 2026 +0200
Change aim state into flag
commit fbb3a84a12e2cabff9b36390da7483b8de7e9379
Author: TheThomaas <thethomaas@protonmail.ch>
Date: Sat Oct 17 18:33:08 2026 +0200
Replace fixed references with ui references
commit 913955b13e9980780ac88761845d9e1f165f0d0e
Author: TheThomaas <thethomaas@protonmail.ch>
Date: Fri Oct 16 13:32:21 2026 +0200
Update camera action handling
commit 4ce0ac13ffea473cf62c2fefd1571e9df1fbbcaa
Author: TheThomaas <thethomaas@protonmail.ch>
Date: Fri Oct 16 13:04:39 2026 +0200
Update mounting system
commit e410eca38760955b2866eecd6ac0281e2041e76d
Author: TheThomaas <thethomaas@protonmail.ch>
Date: Fri Oct 16 12:57:25 2026 +0200
Update aiming system
commit 4c788df485ccbff5f91fd51d9f480e495f11da5f
Author: TheThomaas <thethomaas@protonmail.ch>
Date: Thu Oct 15 21:50:26 2026 +0200
Centralize states names into constants
commit 6059479c87d749e986a48adb520ef33121104da5
Author: TheThomaas <thethomaas@protonmail.ch>
Date: Thu Oct 15 21:25:32 2026 +0200
Refator Crouch state into flag
commit 08faec70e770042d36eed6f173a63f3aac1f67c6
Author: TheThomaas <thethomaas@protonmail.ch>
Date: Wed Oct 14 10:19:35 2026 +0200
Update player input management and state machine
commit 11a0aecc58c50c5862a03b4fd0b55e8db024031f
Author: TheThomaas <thethomaas@protonmail.ch>
Date: Wed Oct 14 10:17:06 2026 +0200
Delete charizard.tres
commit 399eac2b6c64f242a1c2e12360d811127f87681c
Author: TheThomaas <thethomaas@protonmail.ch>
Date: Tue Oct 13 18:20:45 2026 +0200
Remove unused MountedState
commit 42a3668c52fe96a7509a74290a94fc5a8084b713
Author: TheThomaas <thethomaas@protonmail.ch>
Date: Tue Oct 13 18:18:08 2026 +0200
Group grounded states under common class
69 lines
2.5 KiB
GDScript
69 lines
2.5 KiB
GDScript
extends PlayerState
|
|
|
|
class_name DodgeState
|
|
|
|
@export var dodge_speed_curve : Curve #optionnel : controle le "falloff" de vitesse pendant la roulade (1.0 = pleine vitesse, 0.0 = arret). Laisser vide pour une vitesse constante.
|
|
|
|
var dodge_dir : Vector2 = Vector2.ZERO
|
|
var dodge_timer : float = 0.0
|
|
var dodge_duration_ref : float = 0.0
|
|
|
|
func on_enter() -> void:
|
|
AimReticle.hide_instance() #pas de reticule pendant la roulade (si la visee est maintenue, elle reprend apres)
|
|
verifications()
|
|
|
|
func verifications() -> void:
|
|
player.floor_snap_length = 1.0
|
|
player.is_dodging = true
|
|
player.dodge_cooldown = player.dodge_cooldown_ref
|
|
|
|
#roule dans la direction actuelle de l'input, ou dans la derniere direction connue si aucune touche n'est tenue (comportement Arceus)
|
|
dodge_dir = player.move_dir if player.move_dir != Vector2.ZERO else player.last_input_dir
|
|
if dodge_dir == Vector2.ZERO: dodge_dir = Vector2.DOWN #direction par defaut si le perso n'a encore jamais bouge
|
|
dodge_dir = dodge_dir.normalized()
|
|
|
|
dodge_timer = player.dodge_duration
|
|
dodge_duration_ref = player.dodge_duration
|
|
|
|
#oriente immediatement le modele dans la direction de la roulade, verrouillee pour toute sa duree
|
|
player.visual_root.rotation.y = -dodge_dir.orthogonal().angle()
|
|
|
|
func exit() -> void:
|
|
player.is_dodging = false
|
|
|
|
func physics_update(delta : float) -> void:
|
|
applies()
|
|
|
|
player.gravity_apply(delta)
|
|
|
|
move(delta)
|
|
|
|
dodge_timer -= delta
|
|
if dodge_timer <= 0.0:
|
|
end_dodge()
|
|
|
|
func applies() -> void:
|
|
#si le perso quitte le sol en roulant (ex: roulade vers un bord), on bascule vers InairState comme les autres etats au sol
|
|
if !player.is_on_floor() and !player.is_on_wall():
|
|
if player.velocity.y < 0.0:
|
|
fall()
|
|
|
|
func move(_delta : float) -> void:
|
|
if !player.is_on_floor(): return
|
|
|
|
#falloff de vitesse : pleine vitesse par defaut, ou modele par dodge_speed_curve si assignee
|
|
var ratio : float = 1.0
|
|
if dodge_speed_curve:
|
|
ratio = dodge_speed_curve.sample(1.0 - (dodge_timer / dodge_duration_ref))
|
|
|
|
player.velocity.x = dodge_dir.x * player.dodge_speed * ratio
|
|
player.velocity.z = dodge_dir.y * player.dodge_speed * ratio
|
|
|
|
func end_dodge() -> void:
|
|
#a la fin de la roulade, retour a l'etat approprie (la posture accroupie est conservee : Idle / Walk la reappliquent)
|
|
if !player.is_on_floor():
|
|
fall()
|
|
else:
|
|
if input.aim_held(): player.aim_targeting.begin_aim() #visee enfoncee pendant la roulade (sans effet si la visee est deja active)
|
|
request_ground_state(player.move_dir != Vector2.ZERO)
|