I have a random object with a random size that is chosen at the start. The selected size effects my height and width variables. My code does what I want, but there’s a lot of if functions which is not pretty. I want to know if there is something I could look into to simplify this code into fewer lines and “if” functions.
Here’s the code:
if (PlanetSpawner.randomSize >= 0.5f && PlanetSpawner.randomSize < 0.6f) {
width = 2.8f;
height = 2.8f;
}
if (PlanetSpawner.randomSize >= 0.6f && PlanetSpawner.randomSize < 0.7f) {
width = 3.0f;
height = 3.0f;
}
if (PlanetSpawner.randomSize >= 0.7f && PlanetSpawner.randomSize < 0.8f) {
width = 3.2f;
height = 3.2f;
}
if (PlanetSpawner.randomSize >= 0.8f && PlanetSpawner.randomSize < 0.9f) {
width = 3.4f;
height = 3.4f;
}
if (PlanetSpawner.randomSize >= 0.9f && PlanetSpawner.randomSize < 1.0f) {
width = 3.6f;
height = 3.6f;
}
if (PlanetSpawner.randomSize >= 1.0f && PlanetSpawner.randomSize < 1.1f) {
width = 3.8f;
height = 3.8f;
}
if (PlanetSpawner.randomSize >= 1.1f && PlanetSpawner.randomSize < 1.2f) {
width = 4.0f;
height = 4.0f;
}
if (PlanetSpawner.randomSize >= 1.2f && PlanetSpawner.randomSize < 1.3f) {
width = 4.2f;
height = 4.2f;
}
if (PlanetSpawner.randomSize >= 1.3f && PlanetSpawner.randomSize < 1.4f) {
width = 4.4f;
height = 4.4f;
}
if (PlanetSpawner.randomSize >= 1.4f && PlanetSpawner.randomSize < 1.5f) {
width = 4.6f;
height = 4.6f;
}
if (PlanetSpawner.randomSize >= 1.5f && PlanetSpawner.randomSize < 1.6f) {
width = 4.8f;
height = 4.8f;
}
How is randomSize set? What do you want to happen if it's less than 0.5 or greater than 1.6? Do you ever need for width and height to be different from each other?
– tanoshimiHi again, i tried it but i dont get it working- because it doesnt know the "Custom Fixed Update" class. Sorry, im new to coding. If we could get it working- is that also frame independent? Could you pls tell me how go get tha custom fixed update. Must the script and class anme CustomFiexUpdate? Best Regards, K
– K_Tec