Skip to content

Commit

Permalink
feat: bounce threshold to improve movements
Browse files Browse the repository at this point in the history
  • Loading branch information
richardbogad committed Oct 26, 2024
1 parent 8e33fbc commit 538fbbe
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions Assets/Scripts/Infinitra/Movement/Movement.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,9 @@ public class Movement : MonoBehaviour, IMovement

private float crouchTimeElapsed;
private float crouchHeightStart;


private float bounceThreshold;

public void Awake()
{
xrOrigin = GetComponent<XROrigin>();
Expand Down Expand Up @@ -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
{
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -390,6 +392,7 @@ public void applyModelConfig(IModelConfig config)
charaController.slopeLimit = config.charSlope;
charaController.minMoveDistance = config.charMoveDist;
charaController.enableOverlapRecovery = true;
bounceThreshold = config.bounceThreshold;
}
}
}

0 comments on commit 538fbbe

Please sign in to comment.