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
68 lines
2.4 KiB
GDScript
68 lines
2.4 KiB
GDScript
extends PlayerState
|
|
|
|
class_name AirborneState
|
|
|
|
#base des etats en l'air (Jump, Inair), comme GroundedState pour le sol. Chaque etat enfant ne decrit que ses differences :
|
|
# - on_air_enter() : ce qui se passe a l'entree (JumpState saute, InairState applique un saut coupe)
|
|
# - check_apex() : condition pour changer d'etat en l'air (JumpState -> InairState quand le perso commence a descendre)
|
|
# - handle_input() : les inputs propres a l'etat (saut, relachement du saut...)
|
|
#le reste est commun : gravite, minuteurs de saut, atterrissage, collision avec un mur, controle en l'air.
|
|
|
|
#---------- cycle de vie ----------
|
|
|
|
func on_enter() -> void:
|
|
if player.floor_snap_length != 0.0: player.floor_snap_length = 0.0 #sinon le perso reste colle au sol
|
|
on_air_enter()
|
|
|
|
func on_air_enter() -> void:
|
|
pass
|
|
|
|
#---------- boucle ----------
|
|
|
|
func physics_update(delta : float) -> void:
|
|
if check_air_transitions(delta): return
|
|
|
|
player.gravity_apply(delta)
|
|
|
|
if handle_input(): return
|
|
|
|
move(delta)
|
|
|
|
func check_air_transitions(delta : float) -> bool:
|
|
#atterrissage : retour a l'etat au sol correspondant a la derniere allure (marche / course)
|
|
if player.is_on_floor():
|
|
return request_ground_state(player.move_dir != Vector2.ZERO)
|
|
|
|
tick_air_timers(delta)
|
|
if check_apex(): return true
|
|
|
|
#si active, coupe la vitesse horizontale quand le perso touche un mur
|
|
if player.is_on_wall() and player.hit_wall_cut_velocity:
|
|
player.velocity.x = 0.0
|
|
player.velocity.z = 0.0
|
|
return false
|
|
|
|
func tick_air_timers(delta : float) -> void:
|
|
if player.jump_cooldown > 0.0: player.jump_cooldown -= delta
|
|
if player.coyote_jump_cooldown > 0.0: player.coyote_jump_cooldown -= delta
|
|
|
|
func check_apex() -> bool:
|
|
return false #JumpState surcharge
|
|
|
|
func handle_input() -> bool:
|
|
return false #Jump et Inair surchargent
|
|
|
|
#---------- controle en l'air ----------
|
|
|
|
func move(delta : float) -> void:
|
|
player.move_dir = input.read_move_dir()
|
|
if !player.move_dir or player.is_on_floor(): return
|
|
|
|
#selon la derniere allure au sol (marche ou course), on choisit la courbe correspondante pour les valeurs en l'air
|
|
var idx : int = player.locomotion #WALK = 0, RUN = 1 : l'index de la courbe correspondante
|
|
if idx >= player.in_air_move_speed.size() or idx >= player.in_air_accel.size(): return #courbes non assignees
|
|
|
|
var speed : float = player.in_air_move_speed[idx].sample(player.velocity.length())
|
|
var accel : float = player.in_air_accel[idx].sample(player.velocity.length())
|
|
accelerate(speed, accel, delta)
|