Добавлена возможность прыгать во время слайда
Прыжок во время слайда отменяет его, но не уменьшает импульс, созданный слайдом
This commit is contained in:
1 parent
5bf468673f
commit
7114f1136c
2 files changed
+14
-7
No files matched your search
+7
-1
@@ -75,7 +75,7 @@ namespace Code.Gameplay.Character.Controller
|
|||||||
_inputHandler.MoveInputVector = Vector3.zero;
|
_inputHandler.MoveInputVector = Vector3.zero;
|
||||||
_inputHandler.LookInputVector = Vector3.one;
|
_inputHandler.LookInputVector = Vector3.one;
|
||||||
_inputHandler.IsSprinting = false;
|
_inputHandler.IsSprinting = false;
|
||||||
_groundMovement.CancelJumpRequest();
|
_groundMovement.RequestJump(inputs.JumpPressed);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -135,6 +135,12 @@ namespace Code.Gameplay.Character.Controller
|
|||||||
// Обновление скорости движения персонажа
|
// Обновление скорости движения персонажа
|
||||||
public void UpdateVelocity(ref Vector3 currentVelocity, float deltaTime)
|
public void UpdateVelocity(ref Vector3 currentVelocity, float deltaTime)
|
||||||
{
|
{
|
||||||
|
// Если во время слайда запрошен прыжок — прерываем слайд
|
||||||
|
if (_slideMechanic.IsSliding && _groundMovement.JumpRequested)
|
||||||
|
{
|
||||||
|
_slideMechanic.EndSlide();
|
||||||
|
}
|
||||||
|
|
||||||
// Проверяем запрос слайда и запускаем его если можно
|
// Проверяем запрос слайда и запускаем его если можно
|
||||||
if (!_slideMechanic.IsSliding)
|
if (!_slideMechanic.IsSliding)
|
||||||
{
|
{
|
||||||
|
|||||||
+7
-6
@@ -17,8 +17,9 @@ namespace Code.Gameplay.Character.Controller.Movement
|
|||||||
private readonly float _stableMovementSharpness;
|
private readonly float _stableMovementSharpness;
|
||||||
// Скорость прыжка
|
// Скорость прыжка
|
||||||
private readonly float _jumpSpeed;
|
private readonly float _jumpSpeed;
|
||||||
// Флаг указывающий, что был запрошен прыжок
|
|
||||||
private bool _jumpRequested;
|
// Свойство-флаг указывающий, что был запрошен прыжок
|
||||||
|
public bool JumpRequested { get; private set; }
|
||||||
|
|
||||||
// Конструктор системы движения на земле
|
// Конструктор системы движения на земле
|
||||||
public GroundMovementSystem(float maxStableMoveSpeed, float sprintMoveSpeed, float stableMovementSharpness, float jumpSpeed)
|
public GroundMovementSystem(float maxStableMoveSpeed, float sprintMoveSpeed, float stableMovementSharpness, float jumpSpeed)
|
||||||
@@ -33,13 +34,13 @@ namespace Code.Gameplay.Character.Controller.Movement
|
|||||||
public void RequestJump(bool jumpPressed)
|
public void RequestJump(bool jumpPressed)
|
||||||
{
|
{
|
||||||
if (jumpPressed)
|
if (jumpPressed)
|
||||||
_jumpRequested = true;
|
JumpRequested = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Метод для отмены запроса на прыжок извне
|
// Метод для отмены запроса на прыжок извне
|
||||||
public void CancelJumpRequest()
|
public void CancelJumpRequest()
|
||||||
{
|
{
|
||||||
_jumpRequested = false;
|
JumpRequested = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Обновление скорости движения персонажа на земле
|
// Обновление скорости движения персонажа на земле
|
||||||
@@ -76,10 +77,10 @@ namespace Code.Gameplay.Character.Controller.Movement
|
|||||||
);
|
);
|
||||||
|
|
||||||
// Если запрошен прыжок
|
// Если запрошен прыжок
|
||||||
if (_jumpRequested)
|
if (JumpRequested)
|
||||||
{
|
{
|
||||||
currentVelocity += motor.CharacterUp * _jumpSpeed - Vector3.Project(currentVelocity, motor.CharacterUp);
|
currentVelocity += motor.CharacterUp * _jumpSpeed - Vector3.Project(currentVelocity, motor.CharacterUp);
|
||||||
_jumpRequested = false; // Сброс сразу после применения
|
JumpRequested = false; // Сброс сразу после применения
|
||||||
motor.ForceUnground();
|
motor.ForceUnground();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user