private void FixedUpdate() { if (!freeze && !collisionSensor.IsTouchingLeftWall(col.bounds.center, col.bounds.size) && !collisionSensor.IsTouchingRightWall(col.bounds.center, col.bounds.size)) { if (Mathf.Abs(Physics.Vx) < 0.01f) { FreezePosition(); } } else if (freeze && Mathf.Abs(Physics.Vx) > 0.01f) { UnfreezePosition(); } }