Skip to content

Commit 32b84a5

Browse files
committed
adjust bug when the input magnitude is equal 0
1 parent 3ba6bc7 commit 32b84a5

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

Assets/Scripts/Drive.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,11 @@ void Update()
3333

3434
void Translate(Transform transform, Vector3 dir)
3535
{
36-
float angleYAxis = UMath.Angle(Vector3.up, transform.up);
36+
if(Vector3.Distance(Vector3.zero, dir) == 0) return;
37+
38+
float angleYAxis = UMath.Angle(dir, transform.up);
3739

38-
if (UMath.IsDirectionClockWise(Vector3.up, transform.up))
40+
if (UMath.IsDirectionClockWise(dir, transform.up))
3941
{
4042
angleYAxis = 2 * Mathf.PI - angleYAxis;
4143
}

0 commit comments

Comments
 (0)