Убрано НАХУЙ _Recovery, добавлено движение в воздухе, деду добавлен стан как от дэша, так и от слайда, воллран вынесен в конфиг
This commit is contained in:
1 parent
77fd9af29d
commit
b4de41894f
40 files changed
+69
-4526
No files matched your search
@@ -31,5 +31,16 @@ namespace Code.Configs
|
||||
leanSmoothSpeed = 10f;
|
||||
|
||||
public Vector3 gravity = new(0f, -30f, 0f);
|
||||
public float
|
||||
maxAirSpeed = 10f,
|
||||
airControlSharpness = 8f;
|
||||
|
||||
public float
|
||||
wallRunMaxTime = 1.75f,
|
||||
wallRunSpeed = 15f,
|
||||
wallRunAcceleration = 25f,
|
||||
wallRunGravityScale = 0.25f,
|
||||
wallDetachImpulse = 7f,
|
||||
wallContactAngleThreshold = 45f;
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -58,7 +58,7 @@ namespace Code.Gameplay.Character.Controller.Abilities
|
||||
if (_slideDirection.sqrMagnitude < 0.01f) _slideDirection = motor.CharacterForward;
|
||||
|
||||
_initialSpeed = motor.Velocity.magnitude;
|
||||
if (_initialSpeed < 0.1f) _initialSpeed = 12f; // fallback
|
||||
if (_initialSpeed < 12f) _initialSpeed = 12f; // fallback
|
||||
|
||||
_cooldownTimer = _cooldown;
|
||||
_slideRequested = false;
|
||||
|
||||
+16
@@ -32,6 +32,22 @@ namespace Code.Gameplay.Character.Controller.Abilities
|
||||
private CharacterInputHandler _inputHandler;
|
||||
|
||||
public bool IsWallRunning => _isWallRunning;
|
||||
|
||||
public WallRunningMechanic(
|
||||
float maxWallRunTime,
|
||||
float wallRunSpeed,
|
||||
float wallRunAcceleration,
|
||||
float wallRunGravityScale,
|
||||
float wallDetachImpulse,
|
||||
float wallContactAngleThreshold)
|
||||
{
|
||||
MaxWallRunTime = maxWallRunTime;
|
||||
WallRunSpeed = wallRunSpeed;
|
||||
WallRunAcceleration = wallRunAcceleration;
|
||||
WallRunGravityScale = wallRunGravityScale;
|
||||
WallDetachImpulse = wallDetachImpulse;
|
||||
WallContactAngleThreshold = wallContactAngleThreshold;
|
||||
}
|
||||
|
||||
public void Initialize(KinematicCharacterMotor motor, CharacterInputHandler inputHandler)
|
||||
{
|
||||
|
||||
+15
-13
@@ -36,6 +36,7 @@ namespace Code.Gameplay.Character.Controller
|
||||
private AirMovementSystem _airMovement;
|
||||
|
||||
public bool IsSliding => _slideMechanic.IsSliding;
|
||||
public bool IsDashing => _dashMechanic.IsDashing;
|
||||
public bool IsWallRunning => _wallRunningMechanic.IsWallRunning;
|
||||
|
||||
private float abilityBlockTimer;
|
||||
@@ -62,16 +63,14 @@ namespace Code.Gameplay.Character.Controller
|
||||
_characterConfig.slideMinVelocityThreshold,
|
||||
_characterConfig.slideCooldown
|
||||
);
|
||||
_wallRunningMechanic = new WallRunningMechanic();
|
||||
|
||||
// TODO: WallRunningMechanic (можно вынести в конфиг позже)
|
||||
_wallRunningMechanic.MaxWallRunTime = 1.75f;
|
||||
_wallRunningMechanic.WallRunSpeed = 15.0f;
|
||||
_wallRunningMechanic.WallRunAcceleration = 25.0f;
|
||||
_wallRunningMechanic.WallRunGravityScale = 0.25f;
|
||||
_wallRunningMechanic.WallDetachImpulse = 7.0f;
|
||||
_wallRunningMechanic.WallContactAngleThreshold = 45.0f;
|
||||
|
||||
_wallRunningMechanic = new WallRunningMechanic(
|
||||
_characterConfig.wallRunMaxTime,
|
||||
_characterConfig.wallRunSpeed,
|
||||
_characterConfig.wallRunAcceleration,
|
||||
_characterConfig.wallRunGravityScale,
|
||||
_characterConfig.wallDetachImpulse,
|
||||
_characterConfig.wallContactAngleThreshold
|
||||
);
|
||||
_wallLeanMechanic = new WallLeanMechanic(
|
||||
_characterConfig.leanAngle,
|
||||
_characterConfig.leanThreshold,
|
||||
@@ -82,8 +81,11 @@ namespace Code.Gameplay.Character.Controller
|
||||
_characterConfig.stableMovementSharpness,
|
||||
_characterConfig.jumpSpeed
|
||||
);
|
||||
_airMovement = new AirMovementSystem(_characterConfig.gravity);
|
||||
|
||||
_airMovement = new AirMovementSystem(
|
||||
_characterConfig.gravity,
|
||||
_characterConfig.maxAirSpeed,
|
||||
_characterConfig.airControlSharpness
|
||||
);
|
||||
|
||||
motor.CharacterController = this; // Регистрация этого контроллера в движке
|
||||
_inputHandler.FirstPersonCameraRotation =
|
||||
@@ -214,7 +216,7 @@ namespace Code.Gameplay.Character.Controller
|
||||
// Если персонаж не на земле — стандартное воздушное движение
|
||||
else
|
||||
{
|
||||
_airMovement.UpdateVelocity(ref currentVelocity, deltaTime);
|
||||
_airMovement.UpdateVelocity(ref currentVelocity, _inputHandler, motor, deltaTime);
|
||||
_groundMovement.CancelJumpRequest();
|
||||
}
|
||||
}
|
||||
|
||||
+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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -52,7 +52,7 @@ namespace Code.Gameplay.Enemies
|
||||
|
||||
audioService.PlayEnemy(EnemiesSounds.GrandpaAttack,agent.transform.position);
|
||||
|
||||
if (Player.CustomCharacterController.IsSliding)
|
||||
if (Player.CustomCharacterController.IsDashing || Player.CustomCharacterController.IsSliding)
|
||||
ApplyStun();
|
||||
else
|
||||
DealDamage();
|
||||
|
||||
Reference in new issue
Block a user