Quantcast
Channel: Questions in topic: "crash"
Viewing all articles
Browse latest Browse all 2383

Unity crashes after I change 1 symbol in code!

$
0
0
using System.Collections; using System.Collections.Generic; using UnityEngine; public class FlorScript : MonoBehaviour { public int size, sizeleft; public int[] sizeX; public int a,b,c; public GameObject[] objts; // public GameObject lastspwnd; public GameObject pos1; public bool isSpace; private void Start() { sizeleft = size; a = Random.Range(0, 3); Instantiate(objts[a], pos1.transform.position, pos1.transform.rotation); sizeleft -= sizeX[a]; pos1.transform.position -= new Vector3(-3f, 0, 0); isSpace = false; Log(a," <-- First random"); for(int i = 0; i <= 10; i++) //How many objects we can spawn; { for(int k = 0; k <= 3; k++) //Check if there are object that can fill empty space; { isSpace = false; // isSpace set to false to avoid issues; if(sizeleft >= sizeX[k]) // If Yes than stop check; { isSpace = true; Log(k, " break"); break; } } if (!isSpace) // If ther is not empty space than STOP { break; } if (isSpace) // Start searching desired object; { while (isSpace) //repeat cheking until the desired object is found; { a = Random.Range(0, 3); **if (sizeleft >= size[a]) { Instantiate(objts[a], pos1.transform.position, pos1.transform.rotation); sizeleft -= sizeX[a]; isSpace = false; break; }** } } } } public void Log(int value, string massage) { Debug.Log(value + " || " + massage); } } When I change ">=" to "<=" **in last if** it work but on the other wrong way. But if I left everything without changes then Unity crashes and i need to restart it; What's wrong? Thanks) P.S. I'm not a native English speaker)

Viewing all articles
Browse latest Browse all 2383

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>