From 538fbbe90810204f153e719163e1dadea21c77da Mon Sep 17 00:00:00 2001 From: rboga Date: Sun, 25 Feb 2024 17:59:07 +0100 Subject: [PATCH] feat: bounce threshold to improve movements --- Assets/Scripts/Infinitra/Movement/Movement.cs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/Assets/Scripts/Infinitra/Movement/Movement.cs b/Assets/Scripts/Infinitra/Movement/Movement.cs index 9f4f017..30b5c3f 100644 --- a/Assets/Scripts/Infinitra/Movement/Movement.cs +++ b/Assets/Scripts/Infinitra/Movement/Movement.cs @@ -43,7 +43,9 @@ public class Movement : MonoBehaviour, IMovement private float crouchTimeElapsed; private float crouchHeightStart; - + + private float bounceThreshold; + public void Awake() { xrOrigin = GetComponent(); @@ -118,7 +120,7 @@ private void processMove(float deltaTime) if (goUserXr.collDown) { // Bouncing off ground. - if (velocity.y < 0.0) velocity.y = -velocity.y * 0.25f; + if (velocity.y < bounceThreshold) velocity.y = -(velocity.y-bounceThreshold) * 0.25f; } else { @@ -149,7 +151,7 @@ private void processMove(float deltaTime) Vector normalComponent = velocity - parallelComponent; frictionVector = -normalComponent * deltaTime * modelConfig.friction * frictionFactor; - } + } else { frictionVector = -velocity * deltaTime * modelConfig.friction * frictionFactor; @@ -390,6 +392,7 @@ public void applyModelConfig(IModelConfig config) charaController.slopeLimit = config.charSlope; charaController.minMoveDistance = config.charMoveDist; charaController.enableOverlapRecovery = true; + bounceThreshold = config.bounceThreshold; } } } \ No newline at end of file