Skip to content

Commit

Permalink
v2.3.2 Fixed ball stopping criteria
Browse files Browse the repository at this point in the history
more accurate now
  • Loading branch information
ThatAmuzak committed Dec 5, 2024
1 parent a7c0c2c commit 6205c63
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions Assets/_Scripts/Golf/GolfBallController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ private void FixedUpdate()
if (!isMoving) return;
Vector3 direction = (targetPosition - transform.position).normalized;
float distance = Vector3.Distance(transform.position, targetPosition);
if(distance > 0.01f && (rb.velocity.magnitude > 0.02f || distance > 1f))
if(distance > 0.01f && (rb.velocity.magnitude > 0.005f || distance > 1f))
{
float easingFactor = 1 - Mathf.Exp(-distance * 0.22f);
rb.velocity = (direction * (easingFactor * maxSpeed)).XZPlane(-1.2f); //hack to make falling look realistic
Expand Down Expand Up @@ -85,7 +85,7 @@ private void OnDrawGizmos()
{
if (!isMoving) return;
Gizmos.color = Color.blue;
Gizmos.DrawWireSphere(targetPosition, 0.08f);
Gizmos.DrawWireSphere(targetPosition, 0.03f);
}

public void ResetBall()
Expand Down

0 comments on commit 6205c63

Please # to comment.