прорвёмся (добавлен walljump)
This commit is contained in:
1 parent
01d3b0adec
commit
d10d2cdca6
2 files changed
+51
-7
No files matched your search
+35
@@ -204,5 +204,40 @@ namespace Code.Gameplay.Character.Controller.Abilities
|
|||||||
{
|
{
|
||||||
return !_isWallRunning && !_motor.GroundingStatus.IsStableOnGround;
|
return !_isWallRunning && !_motor.GroundingStatus.IsStableOnGround;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void PerformWallJump(CharacterInputs inputs, Quaternion cameraRotation)
|
||||||
|
{
|
||||||
|
if (!_isWallRunning || _motor == null) return;
|
||||||
|
|
||||||
|
_isWallRunning = false;
|
||||||
|
|
||||||
|
Vector3 wallAway = _wallNormal;
|
||||||
|
Vector3 wallUp = _wallTangentUp;
|
||||||
|
|
||||||
|
Vector3 playerForward = cameraRotation * Vector3.forward;
|
||||||
|
|
||||||
|
Vector3 forwardInWallPlane = Vector3.ProjectOnPlane(playerForward, _wallNormal).normalized;
|
||||||
|
if (forwardInWallPlane.sqrMagnitude < 0.01f) forwardInWallPlane = _wallTangentRight;
|
||||||
|
|
||||||
|
Vector3 jumpDirection =
|
||||||
|
forwardInWallPlane * 0.1f +
|
||||||
|
wallAway * 0.5f +
|
||||||
|
wallUp * 0.4f;
|
||||||
|
|
||||||
|
jumpDirection = jumpDirection.normalized;
|
||||||
|
|
||||||
|
float wallJumpForce = WallDetachImpulse * 2f;
|
||||||
|
|
||||||
|
Vector3 jumpImpulse = jumpDirection * wallJumpForce;
|
||||||
|
|
||||||
|
_motor.BaseVelocity += jumpImpulse;
|
||||||
|
|
||||||
|
_motor.SetPosition(_motor.TransientPosition + wallAway * 0.07f);
|
||||||
|
|
||||||
|
if (_motor.CharacterController is CustomCharacterController controller)
|
||||||
|
{
|
||||||
|
controller.BlockAbilities(0.12f);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+16
-7
@@ -30,7 +30,7 @@ namespace Code.Gameplay.Character.Controller
|
|||||||
private SlideMechanic _slideMechanic;
|
private SlideMechanic _slideMechanic;
|
||||||
// private WallClimbMechanic _wallClimbMechanic;
|
// private WallClimbMechanic _wallClimbMechanic;
|
||||||
private WallRunningMechanic _wallRunningMechanic;
|
private WallRunningMechanic _wallRunningMechanic;
|
||||||
private WallLeanMechanic _wallLeanMechanic;
|
//private WallLeanMechanic _wallLeanMechanic;
|
||||||
private GroundMovementSystem _groundMovement;
|
private GroundMovementSystem _groundMovement;
|
||||||
private AirMovementSystem _airMovement;
|
private AirMovementSystem _airMovement;
|
||||||
|
|
||||||
@@ -72,11 +72,11 @@ namespace Code.Gameplay.Character.Controller
|
|||||||
_wallRunningMechanic.WallDetachImpulse = 7.0f;
|
_wallRunningMechanic.WallDetachImpulse = 7.0f;
|
||||||
_wallRunningMechanic.WallContactAngleThreshold = 45.0f;
|
_wallRunningMechanic.WallContactAngleThreshold = 45.0f;
|
||||||
|
|
||||||
_wallLeanMechanic = new WallLeanMechanic(
|
/*_wallLeanMechanic = new WallLeanMechanic(
|
||||||
_characterConfig.maxWallLeanAngle,
|
_characterConfig.maxWallLeanAngle,
|
||||||
_characterConfig.wallLeanSharpness,
|
_characterConfig.wallLeanSharpness,
|
||||||
_characterConfig.wallLeanHeightScale
|
_characterConfig.wallLeanHeightScale
|
||||||
);
|
);*/
|
||||||
_groundMovement = new GroundMovementSystem(
|
_groundMovement = new GroundMovementSystem(
|
||||||
_characterConfig.maxStableMoveSpeed,
|
_characterConfig.maxStableMoveSpeed,
|
||||||
_characterConfig.sprintMoveSpeed,
|
_characterConfig.sprintMoveSpeed,
|
||||||
@@ -89,7 +89,7 @@ namespace Code.Gameplay.Character.Controller
|
|||||||
motor.CharacterController = this; // Регистрация этого контроллера в движке
|
motor.CharacterController = this; // Регистрация этого контроллера в движке
|
||||||
_inputHandler.FirstPersonCameraRotation =
|
_inputHandler.FirstPersonCameraRotation =
|
||||||
motor.Transform.rotation; // Начальное вращение совпадает с персонажемс
|
motor.Transform.rotation; // Начальное вращение совпадает с персонажемс
|
||||||
_wallLeanMechanic.SetCharacterTransform(characterTransform);
|
//_wallLeanMechanic.SetCharacterTransform(characterTransform);
|
||||||
_wallRunningMechanic.Initialize(motor, _inputHandler);
|
_wallRunningMechanic.Initialize(motor, _inputHandler);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -191,7 +191,16 @@ namespace Code.Gameplay.Character.Controller
|
|||||||
// === WALL RUNNING: обработка состояния ===
|
// === WALL RUNNING: обработка состояния ===
|
||||||
if (_wallRunningMechanic.IsWallRunning)
|
if (_wallRunningMechanic.IsWallRunning)
|
||||||
{
|
{
|
||||||
_wallRunningMechanic.HandleWallRun(ref currentVelocity, _lastInputs, deltaTime);
|
// 🔄 Передаём актуальные данные для walljump
|
||||||
|
if (_groundMovement.JumpRequested) // или _lastInputs.JumpPressed — зависит от логики
|
||||||
|
{
|
||||||
|
_wallRunningMechanic.PerformWallJump(_lastInputs, _inputHandler.FirstPersonCameraRotation);
|
||||||
|
_groundMovement.CancelJumpRequest(); // сброс, чтобы не сработало дважды
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_wallRunningMechanic.HandleWallRun(ref currentVelocity, _lastInputs, deltaTime);
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -233,7 +242,7 @@ namespace Code.Gameplay.Character.Controller
|
|||||||
|
|
||||||
public void AfterCharacterUpdate(float deltaTime)
|
public void AfterCharacterUpdate(float deltaTime)
|
||||||
{
|
{
|
||||||
_wallLeanMechanic.UpdateLean(motor, deltaTime);
|
//_wallLeanMechanic.UpdateLean(motor, deltaTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool IsColliderValidForCollisions(Collider coll)
|
public bool IsColliderValidForCollisions(Collider coll)
|
||||||
@@ -252,7 +261,7 @@ namespace Code.Gameplay.Character.Controller
|
|||||||
// Попытка начать Wall Run при ударе о поверхность
|
// Попытка начать Wall Run при ударе о поверхность
|
||||||
if (_wallRunningMechanic.TryStartWallRun(hitNormal, hitPoint))
|
if (_wallRunningMechanic.TryStartWallRun(hitNormal, hitPoint))
|
||||||
{
|
{
|
||||||
_wallLeanMechanic.OnWallContact(motor, hitNormal, motor.TransientPosition.y);
|
//_wallLeanMechanic.OnWallContact(motor, hitNormal, motor.TransientPosition.y);
|
||||||
}
|
}
|
||||||
|
|
||||||
// if (_wallClimbMechanic.TryClimbWall(motor, hitNormal))
|
// if (_wallClimbMechanic.TryClimbWall(motor, hitNormal))
|
||||||
|
|||||||
Reference in new issue
Block a user