Меняется таргет камеры (и высота коллайдера) при слайде
This commit is contained in:
1 parent
eb4dff803e
commit
ecff1e69cd
3 files changed
+74
-2
No files matched your search
@@ -23,7 +23,11 @@ namespace Code.Configs
|
|||||||
);
|
);
|
||||||
public float
|
public float
|
||||||
slideMinVelocityThreshold = 3f,
|
slideMinVelocityThreshold = 3f,
|
||||||
slideCooldown = 1.5f;
|
slideCooldown = 1.5f,
|
||||||
|
slideColliderHeightScale = 0.5f,
|
||||||
|
slideCameraOffsetY = -0.5f,
|
||||||
|
slideEnterDuration = 0.2f,
|
||||||
|
slideExitDuration = 0.25f;
|
||||||
|
|
||||||
public float
|
public float
|
||||||
leanAngle = 25f,
|
leanAngle = 25f,
|
||||||
|
|||||||
+67
-1
@@ -25,6 +25,12 @@ namespace Code.Gameplay.Character.Controller
|
|||||||
|
|
||||||
[SerializeField] private Transform characterTransform; // Трансформ персонажа (с точкой отслеживания камеры)
|
[SerializeField] private Transform characterTransform; // Трансформ персонажа (с точкой отслеживания камеры)
|
||||||
|
|
||||||
|
[SerializeField] private CapsuleCollider _capsuleCollider;
|
||||||
|
[SerializeField] private Transform _cameraFollowPoint;
|
||||||
|
private Vector3 _originalColliderCenter;
|
||||||
|
private float _originalColliderHeight;
|
||||||
|
private Vector3 _originalFollowPointLocalPosition;
|
||||||
|
|
||||||
// Подсистемы
|
// Подсистемы
|
||||||
private CharacterInputHandler _inputHandler;
|
private CharacterInputHandler _inputHandler;
|
||||||
private DashMechanic _dashMechanic;
|
private DashMechanic _dashMechanic;
|
||||||
@@ -92,6 +98,17 @@ namespace Code.Gameplay.Character.Controller
|
|||||||
motor.Transform.rotation; // Начальное вращение совпадает с персонажемс
|
motor.Transform.rotation; // Начальное вращение совпадает с персонажемс
|
||||||
_wallLeanMechanic.SetModel(characterTransform);
|
_wallLeanMechanic.SetModel(characterTransform);
|
||||||
_wallRunningMechanic.Initialize(motor);
|
_wallRunningMechanic.Initialize(motor);
|
||||||
|
|
||||||
|
if (_capsuleCollider != null)
|
||||||
|
{
|
||||||
|
_originalColliderCenter = _capsuleCollider.center;
|
||||||
|
_originalColliderHeight = _capsuleCollider.height;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_cameraFollowPoint != null)
|
||||||
|
{
|
||||||
|
_originalFollowPointLocalPosition = _cameraFollowPoint.localPosition;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Текущий режим камеры для адаптации поведения
|
// Текущий режим камеры для адаптации поведения
|
||||||
@@ -185,11 +202,26 @@ namespace Code.Gameplay.Character.Controller
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!_slideMechanic.IsSliding)
|
if (!_slideMechanic.IsSliding)
|
||||||
|
{
|
||||||
_slideMechanic.TryStartSlide(motor, _currentCameraMode, _inputHandler.FirstPersonCameraRotation, _inputHandler.LookInputVector);
|
_slideMechanic.TryStartSlide(motor, _currentCameraMode, _inputHandler.FirstPersonCameraRotation, _inputHandler.LookInputVector);
|
||||||
|
|
||||||
|
if (_slideMechanic.IsSliding)
|
||||||
|
{
|
||||||
|
EnterSlideState();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ExitSlideState();
|
||||||
|
}
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
_slideMechanic.HandleSlide(ref currentVelocity, deltaTime, motor);
|
_slideMechanic.HandleSlide(ref currentVelocity, deltaTime, motor);
|
||||||
return;
|
|
||||||
|
if (!_slideMechanic.IsSliding)
|
||||||
|
{
|
||||||
|
ExitSlideState();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// === WALL RUNNING: обработка состояния ===
|
// === WALL RUNNING: обработка состояния ===
|
||||||
@@ -227,6 +259,40 @@ namespace Code.Gameplay.Character.Controller
|
|||||||
abilityBlockTimer = duration;
|
abilityBlockTimer = duration;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void EnterSlideState()
|
||||||
|
{
|
||||||
|
if (_capsuleCollider)
|
||||||
|
{
|
||||||
|
var newHeight = _originalColliderHeight * _characterConfig.slideColliderHeightScale;
|
||||||
|
|
||||||
|
_capsuleCollider.height = newHeight;
|
||||||
|
|
||||||
|
var newCenterY = newHeight * 0.5f - _originalColliderHeight * 0.5f;
|
||||||
|
_capsuleCollider.center = _originalColliderCenter + Vector3.up * newCenterY;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!_cameraFollowPoint) return;
|
||||||
|
|
||||||
|
var offset = Vector3.up * _characterConfig.slideCameraOffsetY;
|
||||||
|
_cameraFollowPoint.localPosition = _originalFollowPointLocalPosition + offset;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ExitSlideState()
|
||||||
|
{
|
||||||
|
if (_capsuleCollider)
|
||||||
|
{
|
||||||
|
_capsuleCollider.height = _originalColliderHeight;
|
||||||
|
_capsuleCollider.center = _originalColliderCenter;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_cameraFollowPoint)
|
||||||
|
{
|
||||||
|
_cameraFollowPoint.localPosition = _originalFollowPointLocalPosition;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public void BeforeCharacterUpdate(float deltaTime)
|
public void BeforeCharacterUpdate(float deltaTime)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -173,6 +173,8 @@ MonoBehaviour:
|
|||||||
m_EditorClassIdentifier: Assembly-CSharp::Code.Gameplay.Player.CharacterController
|
m_EditorClassIdentifier: Assembly-CSharp::Code.Gameplay.Player.CharacterController
|
||||||
motor: {fileID: 8476708390679839925}
|
motor: {fileID: 8476708390679839925}
|
||||||
characterTransform: {fileID: 4122797476271397740}
|
characterTransform: {fileID: 4122797476271397740}
|
||||||
|
_capsuleCollider: {fileID: 8541228187116599584}
|
||||||
|
_cameraFollowPoint: {fileID: 1047840484662430186}
|
||||||
--- !u!114 &3283650228831796584
|
--- !u!114 &3283650228831796584
|
||||||
MonoBehaviour:
|
MonoBehaviour:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
|
|||||||
Reference in new issue
Block a user