update Constrained Scripts Optimizations

This commit is contained in:
Philip W 2021-11-01 00:42:01 +00:00
parent f767c26200
commit 5088c2dfdc
2 changed files with 2 additions and 2 deletions

View File

@ -43,7 +43,7 @@ public class MoveHorizontalConstrained : Physics2DObject
void FixedUpdate()
{
//Sets the objects velocity to 0 if it hits the constrained bounds
if ((this.transform.position.x >= constraintOffsetXPosition && moveHorizontal >= 0f) || (this.transform.position.x <= (constraintOffsetXPosition * -1) && moveHorizontal <= 0f))
if ((this.transform.position.x >= constraintOffsetXPosition && moveHorizontal >= 0f) || (this.transform.position.x <= -constraintOffsetXPosition && moveHorizontal <= 0f))
{
rigidbody2D.velocity = new Vector2(0f, 0f);
}

View File

@ -37,7 +37,7 @@ public class RotateConstrained : Physics2DObject
void FixedUpdate()
{
//Freezes the objects rotation if it hits the constrained bounds
if ((this.transform.rotation.z >= constraintRotationAmount && spin <= 0f) || (this.transform.rotation.z <= (constraintRotationAmount * -1) && spin >= 0f))
if ((this.transform.rotation.z >= constraintRotationAmount && spin <= 0f) || (this.transform.rotation.z <= -constraintRotationAmount && spin >= 0f))
{
rigidbody2D.freezeRotation = true;
}