public void movePillars() { P1B.GetComponent <Rigidbody2D>().velocity = new Vector2((p1 - pillarSpeed), 0); p1T.GetComponent <Rigidbody2D>().velocity = new Vector2((p2 - pillarSpeed), 0); P2B.GetComponent <Rigidbody2D>().velocity = new Vector2((p3 - pillarSpeed), 0); P2T.GetComponent <Rigidbody2D>().velocity = new Vector2((p4 - pillarSpeed), 0); if (P1B.transform.position.x <= -6.35 && p1T.transform.position.x <= -6.35) { P1 = P2 = false; P1B.transform.position = new Vector3(6.31f, (int)UnityEngine.Random.RandomRange(-2f, -5f), -2.1f); p1T.transform.position = new Vector3(P1B.transform.position.x + 4f, (int)UnityEngine.Random.RandomRange(3f, 6f), -2.1f); } if (P2B.transform.position.x <= -6.35 && P2T.transform.position.x <= -6.35) { P3 = P4 = false; P2B.transform.position = new Vector3(6.31f, (int)UnityEngine.Random.RandomRange(-2f, -5f), -2.1f); P2T.transform.position = new Vector3(P2B.transform.position.x + 4f, (int)UnityEngine.Random.RandomRange(3f, 6f), -2.1f); } }