update Constrained Scripts Optimizations
This commit is contained in:
parent
f767c26200
commit
5088c2dfdc
@ -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);
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user