![c# – Why is my code crashing Unity? c# – Why is my code crashing Unity?](https://thefuntrove.com/wp-content/uploads/https://cdn.sstatic.net/Sites/gamedev/Img/apple-touch-icon@2.png?v=9bca23db2259)
[ad_1]
I’m making a quite simple world era script for my RimWorld like recreation. However, the script is simply crashing Unity and has damaged my Spotify for the second on the time of asking this. Is there any manner that I might repair my code in a manner that works considerably?
Here is my code:
utilizing System.Collections;
utilizing System.Collections.Generic;
utilizing UnityEngine;
public class GenerateMap : MonoBehaviour
{
public int startingValue;
public int maxValue;
public int minValue;
public int width;
public int top;
public GameObject mountain;
public GameObject floor;
public GameObject water;
personal void Start()
{
for (int x = 0; x < width; x++)
{
for (int y = 0; x < top; y++)
{
int desiredValue = startingValue + Random.Range(minValue, maxValue);
if (desiredValue <= 3 && desiredValue >= -3)
{
Instantiate(floor, new Vector3(x, y, 5), Quaternion.id);
}
if (desiredValue <= 4)
{
Instantiate(mountain, new Vector3(x, y, 5), Quaternion.id);
}
if (desiredValue >= -4)
{
Instantiate(water, new Vector3(x, y, 5), Quaternion.id);
}
}
}
}
}
[ad_2]