Убрано НАХУЙ _Recovery, добавлено движение в воздухе, деду добавлен стан как от дэша, так и от слайда, воллран вынесен в конфиг
This commit is contained in:
1 parent
77fd9af29d
commit
b4de41894f
40 files changed
+69
-4526
No files matched your search
+23
-11
@@ -1,26 +1,38 @@
|
||||
using UnityEngine;
|
||||
using Code.Gameplay.Character.Controller.Input;
|
||||
using KinematicCharacterController;
|
||||
|
||||
namespace Code.Gameplay.Character.Controller.Movement
|
||||
{
|
||||
/*
|
||||
* Система движения персонажа в воздухе
|
||||
*/
|
||||
public class AirMovementSystem
|
||||
{
|
||||
// Вектор, отвечающий за применение гравитации
|
||||
private readonly Vector3 _gravity;
|
||||
|
||||
// Конструктор системы движения в воздухе
|
||||
public AirMovementSystem(Vector3 gravity)
|
||||
private readonly float _maxAirSpeed;
|
||||
private readonly float _airControlSharpness;
|
||||
|
||||
public AirMovementSystem(Vector3 gravity, float maxAirSpeed, float airControlSharpness)
|
||||
{
|
||||
_gravity = gravity;
|
||||
_maxAirSpeed = maxAirSpeed;
|
||||
_airControlSharpness = airControlSharpness;
|
||||
}
|
||||
|
||||
// Обновление скорости движения персонажа в воздухе
|
||||
public void UpdateVelocity(ref Vector3 currentVelocity, float deltaTime)
|
||||
|
||||
public void UpdateVelocity(ref Vector3 currentVelocity, CharacterInputHandler inputHandler, KinematicCharacterMotor motor, float deltaTime)
|
||||
{
|
||||
// Применяем гравитацию
|
||||
currentVelocity += _gravity * deltaTime;
|
||||
|
||||
var horizontalVelocity = Vector3.ProjectOnPlane(currentVelocity, motor.CharacterUp);
|
||||
var verticalVelocity = Vector3.Dot(currentVelocity, motor.CharacterUp) * motor.CharacterUp;
|
||||
|
||||
var desiredHorizontalMovement = Vector3.ProjectOnPlane(inputHandler.MoveInputVector, motor.CharacterUp).normalized * _maxAirSpeed;
|
||||
|
||||
horizontalVelocity = Vector3.Lerp(
|
||||
horizontalVelocity,
|
||||
desiredHorizontalMovement,
|
||||
1f - Mathf.Exp(-_airControlSharpness * deltaTime)
|
||||
);
|
||||
|
||||
currentVelocity = horizontalVelocity + verticalVelocity;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user