From d2c5c45604d2c77d71a049f19bec3ba5548dfe63 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C5=A1a=20Ceviel?= Date: Fri, 5 Dec 2025 08:37:16 +0300 Subject: [PATCH] =?UTF-8?q?=D0=BD=D0=B5=D0=B1=D0=BE=D0=BB=D1=8C=D1=88?= =?UTF-8?q?=D0=BE=D0=B9=20=D1=84=D0=B8=D0=BA=D1=81=D0=B8=D0=BA=20(=D1=81?= =?UTF-8?q?=D0=B8=D0=BC=D0=BA=D0=B0)=20=D0=B2=D0=BE=D0=BB=D0=BB=D1=80?= =?UTF-8?q?=D0=B0=D0=BD=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Abilities/WallRunningMechanic.cs | 27 ++++++++++++++----- 1 file changed, 20 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 5043fa7..33470db 100644 --- a/Game/CourierOld/Assets/Code/Gameplay/Character/Controller/Abilities/WallRunningMechanic.cs +++ b/Game/CourierOld/Assets/Code/Gameplay/Character/Controller/Abilities/WallRunningMechanic.cs @@ -88,12 +88,25 @@ namespace Code.Gameplay.Character.Controller.Abilities var forwardInWallPlane = Vector3.ProjectOnPlane(_motor.CharacterForward, _wallNormal).normalized; if (forwardInWallPlane.sqrMagnitude < 0.01f) { - var fallbackRight = Vector3.Cross(_wallNormal, _wallTangentUp).normalized; + var candidateRight = Vector3.Cross(_wallNormal, _motor.CharacterUp); + candidateRight = Vector3.ProjectOnPlane(candidateRight, _wallNormal).normalized; + + if (candidateRight.sqrMagnitude < 0.01f) + { + candidateRight = Vector3.Cross(_wallNormal, Vector3.up); + candidateRight = Vector3.ProjectOnPlane(candidateRight, _wallNormal).normalized; + } + + if (candidateRight.sqrMagnitude < 0.01f) + { + candidateRight = Vector3.Cross(_wallNormal, Vector3.right).normalized; + } + var dotWithRight = Vector3.Dot(_motor.CharacterRight, _wallNormal); - forwardInWallPlane = dotWithRight < 0 ? fallbackRight : -fallbackRight; + forwardInWallPlane = dotWithRight < 0 ? candidateRight : -candidateRight; } - _wallTangentRight = forwardInWallPlane; + _wallTangentRight = forwardInWallPlane.normalized; _wallTangentUp = Vector3.Cross(_wallTangentRight, -_wallNormal).normalized; _motor.ForceUnground(); @@ -189,13 +202,13 @@ namespace Code.Gameplay.Character.Controller.Abilities { if (!IsWallRunning || !_motor) return; - if (_motor.CharacterController is not CustomCharacterController controller || !controller.CanJump) + if (_motor.CharacterController is not CustomCharacterController { CanJump: true } controller) return; IsWallRunning = false; var wallAway = _wallNormal; - var wallUp = _wallTangentUp; + var wallUp = Vector3.ProjectOnPlane(_motor.CharacterUp, _wallNormal).normalized; var playerForward = cameraRotation * Vector3.forward; @@ -204,8 +217,8 @@ namespace Code.Gameplay.Character.Controller.Abilities var jumpDirection = forwardInWallPlane * 0.2f + - wallAway * 0.4f + - wallUp * 0.4f; + wallAway * 0.6f + + wallUp * 0.2f; jumpDirection = jumpDirection.normalized;