I am making a maze that builds itself from prefabs and I got into a problem that the unity editor freezes sometimes when running the script, i have tried identifying the problem but i cant seem to find it, the assets are fine I made and tested them myself but i cant seem to find a reason for the crash.
any help would be welcomed
----------
public void Build(Transform exit, int q, int d, bool finish)
{
if (q > 0 || d > 0)
{
bool LeftFreeBool, RightFreeBool, ForwardFreeBool;
LeftFreeBool = LeftSmallFree(exit);
RightFreeBool = RightSmallFree(exit);
ForwardFreeBool = ForwardFree(exit);
if (LeftFreeBool && RightFreeBool && ForwardFreeBool)
{
GameObject Temp = BuildRandom(exit, exit.rotation);
if (Temp.transform.CompareTag("T_Junction"))
{
Build(Temp.transform.Find("ExitPoint_Right").transform, q, d - 1, finish);
Build(Temp.transform.Find("ExitPoint_Left").transform, q, d - 1, finish);
}
else if (Temp.transform.name.Equals("Question_Room"))
{
Build(Temp.transform.Find("ExitPoint").transform, q - 1, d - 1, finish);
}
else
{
Build(Temp.transform.Find("ExitPoint").transform, q, d - 1, finish);
}
}
else if (!ForwardFreeBool && LeftFreeBool && RightFreeBool)
{
GameObject Temp = BuildLeftRightJucntion(exit, exit.rotation);
if (Temp.transform.CompareTag("T_Junction"))
{
Build(Temp.transform.Find("ExitPoint_Right").transform, q, d - 1, finish);
Build(Temp.transform.Find("ExitPoint_Left").transform, q, d - 1, finish);
}
else
{
Build(Temp.transform.Find("ExitPoint").transform, q, d - 1, finish);
}
}
else if (ForwardFreeBool && LeftFreeBool && !RightFreeBool)
{
GameObject Temp = BuildRandomLeftForward(exit, exit.rotation);
Build(Temp.transform.Find("ExitPoint").transform, q, d - 1, finish);
}
else if (ForwardFreeBool && !LeftFreeBool && RightFreeBool)
{
GameObject Temp = BuildRandomRightForward(exit, exit.rotation);
Build(Temp.transform.Find("ExitPoint").transform, q, d - 1, finish);
}
else if (!ForwardFreeBool && LeftFreeBool && !RightFreeBool)
{
GameObject Temp = BuildLeftSmall(exit, exit.rotation);
Build(Temp.transform.Find("ExitPoint").transform, q, d - 1, finish);
}
else if (!ForwardFreeBool && !LeftFreeBool && RightFreeBool)
{
GameObject Temp = BuildRightSmall(exit, exit.rotation);
Build(Temp.transform.Find("ExitPoint").transform, q, d - 1, finish);
}
else if (ForwardFreeBool && !LeftFreeBool && !RightFreeBool)
{
GameObject Temp = BuildForward(exit, exit.rotation);
Build(Temp.transform.Find("ExitPoint").transform, q, d - 1, finish);
}
else
{
q = 0;
d = 0;
}
}
}
↧