From d10d2cdca6dea582bafe7e030954a6d85345c2ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C5=A1a=20Ceviel?= Date: Thu, 27 Nov 2025 21:36:19 +0300 Subject: [PATCH] =?UTF-8?q?=D0=BF=D1=80=D0=BE=D1=80=D0=B2=D1=91=D0=BC?= =?UTF-8?q?=D1=81=D1=8F=20(=D0=B4=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=20walljump)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Abilities/WallRunningMechanic.cs | 35 +++++++++++++++++++ .../Controller/CustomCharacterController.cs | 23 ++++++++---- 2 files changed, 51 insertions(+), 7 deletions(-) diff --git a/Game/CourierOld/Assets/Code/Gameplay/Character/Controller/Abilities/WallRunningMechanic.cs b/Game/CourierOld/Assets/Code/Gameplay/Character/Controller/Abilities/WallRunningMechanic.cs index e9aed73..f1b4b7e 100644 --- a/Game/CourierOld/Assets/Code/Gameplay/Character/Controller/Abilities/WallRunningMechanic.cs +++ b/Game/CourierOld/Assets/Code/Gameplay/Character/Controller/Abilities/WallRunningMechanic.cs @@ -204,5 +204,40 @@ namespace Code.Gameplay.Character.Controller.Abilities { 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); + } + } } } \ No newline at end of file diff --git a/Game/CourierOld/Assets/Code/Gameplay/Character/Controller/CustomCharacterController.cs b/Game/CourierOld/Assets/Code/Gameplay/Character/Controller/CustomCharacterController.cs index 3358968..ec5b867 100644 --- a/Game/CourierOld/Assets/Code/Gameplay/Character/Controller/CustomCharacterController.cs +++ b/Game/CourierOld/Assets/Code/Gameplay/Character/Controller/CustomCharacterController.cs @@ -30,7 +30,7 @@ namespace Code.Gameplay.Character.Controller private SlideMechanic _slideMechanic; // private WallClimbMechanic _wallClimbMechanic; private WallRunningMechanic _wallRunningMechanic; - private WallLeanMechanic _wallLeanMechanic; + //private WallLeanMechanic _wallLeanMechanic; private GroundMovementSystem _groundMovement; private AirMovementSystem _airMovement; @@ -72,11 +72,11 @@ namespace Code.Gameplay.Character.Controller _wallRunningMechanic.WallDetachImpulse = 7.0f; _wallRunningMechanic.WallContactAngleThreshold = 45.0f; - _wallLeanMechanic = new WallLeanMechanic( + /*_wallLeanMechanic = new WallLeanMechanic( _characterConfig.maxWallLeanAngle, _characterConfig.wallLeanSharpness, _characterConfig.wallLeanHeightScale - ); + );*/ _groundMovement = new GroundMovementSystem( _characterConfig.maxStableMoveSpeed, _characterConfig.sprintMoveSpeed, @@ -89,7 +89,7 @@ namespace Code.Gameplay.Character.Controller motor.CharacterController = this; // Регистрация этого контроллера в движке _inputHandler.FirstPersonCameraRotation = motor.Transform.rotation; // Начальное вращение совпадает с персонажемс - _wallLeanMechanic.SetCharacterTransform(characterTransform); + //_wallLeanMechanic.SetCharacterTransform(characterTransform); _wallRunningMechanic.Initialize(motor, _inputHandler); } @@ -191,7 +191,16 @@ namespace Code.Gameplay.Character.Controller // === WALL RUNNING: обработка состояния === 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; } @@ -233,7 +242,7 @@ namespace Code.Gameplay.Character.Controller public void AfterCharacterUpdate(float deltaTime) { - _wallLeanMechanic.UpdateLean(motor, deltaTime); + //_wallLeanMechanic.UpdateLean(motor, deltaTime); } public bool IsColliderValidForCollisions(Collider coll) @@ -252,7 +261,7 @@ namespace Code.Gameplay.Character.Controller // Попытка начать Wall Run при ударе о поверхность if (_wallRunningMechanic.TryStartWallRun(hitNormal, hitPoint)) { - _wallLeanMechanic.OnWallContact(motor, hitNormal, motor.TransientPosition.y); + //_wallLeanMechanic.OnWallContact(motor, hitNormal, motor.TransientPosition.y); } // if (_wallClimbMechanic.TryClimbWall(motor, hitNormal))