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
56 lines
2.3 KiB
GDScript
56 lines
2.3 KiB
GDScript
class_name MountSeat
|
|
|
|
#la selle : la monture suit le joueur (position + orientation du modele), le joueur est assis a la selle,
|
|
#et la camera monte progressivement a hauteur de selle. Pas de node : MountRider le cree et l'appelle chaque frame.
|
|
#
|
|
#les decalages (selle, hauteur de camera) sont appliques "en delta" sur visual_root et cam_holder, pour ne pas
|
|
#ecraser les autres reglages de position. Tout cela est regroupe ici : si un jour ces nodes recoivent un vrai
|
|
#decalage dedie (ex : un node Seat), il n'y aura que ce fichier a changer.
|
|
|
|
var _player : PlayerCharacter
|
|
var _visual_root : Node3D
|
|
var _cam_holder : Node3D
|
|
|
|
var _mount : SentPokemon = null
|
|
var _profile : MountProfile = null
|
|
var _seat_applied : Vector3 = Vector3.ZERO #decalage de selle actuellement ajoute a visual_root.position
|
|
var _cam_rise : float = 0.0 #hauteur actuellement ajoutee a cam_holder.position.y
|
|
|
|
func _init(player : PlayerCharacter, visual_root : Node3D, cam_holder : Node3D) -> void:
|
|
_player = player
|
|
_visual_root = visual_root
|
|
_cam_holder = cam_holder
|
|
|
|
func attach(mount : SentPokemon, profile : MountProfile) -> void:
|
|
_mount = mount
|
|
_profile = profile
|
|
|
|
func detach() -> void:
|
|
#le joueur retrouve sa position ; la camera redescend progressivement (update continue de tourner)
|
|
_visual_root.position -= _seat_applied
|
|
_seat_applied = Vector3.ZERO
|
|
_mount = null
|
|
_profile = null
|
|
|
|
func update(delta : float, camera_follow_speed : float) -> void:
|
|
var rise_target : float = 0.0
|
|
|
|
if _mount != null and is_instance_valid(_mount):
|
|
#la monture suit le joueur (position + orientation du modele)
|
|
_mount.global_position = _player.global_position
|
|
var yaw : float = _visual_root.global_rotation.y
|
|
if !SentPokemon.MODEL_FACES_PLUS_Z: yaw += PI
|
|
_mount.global_rotation = Vector3(0.0, yaw, 0.0)
|
|
|
|
#le joueur est assis a la selle (seat_offset est exprime dans le repere de la monture)
|
|
var seat : Vector3 = _mount.global_basis * _profile.seat_offset
|
|
_visual_root.position += seat - _seat_applied
|
|
_seat_applied = seat
|
|
rise_target = _profile.seat_offset.y
|
|
|
|
#la camera monte progressivement a hauteur de selle (en delta : ne gene pas les autres reglages de hauteur)
|
|
var new_rise : float = lerpf(_cam_rise, rise_target, clampf(camera_follow_speed * delta, 0.0, 1.0))
|
|
if absf(new_rise - rise_target) < 0.001: new_rise = rise_target
|
|
_cam_holder.position.y += new_rise - _cam_rise
|
|
_cam_rise = new_rise
|