public void PlatformMovement() { if (!thePlatforms.hitBound) { thePlatforms.GetComponent <Rigidbody2D>().velocity = new Vector2(0.0f, ySpeed); } else if (thePlatforms.hitBound) { thePlatforms.GetComponent <Rigidbody2D>().velocity = new Vector2(0.0f, -ySpeed); } if (thePlatforms.theBatsOnPlatform && !Input.GetButton("Jump")) { theBats.GetComponent <Rigidbody2D>().velocity = thePlatforms.GetComponent <Rigidbody2D>().velocity; } if (!thePlatforms1.hitBound) { thePlatforms1.GetComponent <Rigidbody2D>().velocity = new Vector2(xSpeed, 0.0f); } else if (thePlatforms1.hitBound) { thePlatforms1.GetComponent <Rigidbody2D>().velocity = new Vector2(-xSpeed, 0.0f); } if (Input.GetButton("Jump")) { thePlatforms.theBatsOnPlatform = false; } for (int i = 0; i < 3; ++i) { if (platforms[i].theBatsOnPlatform && !platforms[i].onFloor) { platforms[i].GetComponent <Rigidbody2D>().velocity = new Vector2(0.0f, -51.0f); if (!Input.GetButton("Jump")) { theBats.GetComponent <Rigidbody2D>().velocity = platforms[i].GetComponent <Rigidbody2D>().velocity; } } if (platforms[i].onFloor) { platforms[i].GetComponent <Rigidbody2D>().velocity = new Vector2(0.0f, 0.0f); } if (!platforms[i].theBatsOnPlatform && !platforms[i].hitBound) { platforms[i].GetComponent <Rigidbody2D>().velocity = new Vector2(0.0f, 51.0f); platforms[i].onFloor = false; } if (!platforms[i].theBatsOnPlatform) { platforms[i].onFloor = false; } if (platforms[i].theBatsOnPlatform) { platforms[i].hitBound = false; } } }