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

Function causing Unity to stop responding

$
0
0
I'm creating a series of cubes arranged in a circle and then spreading them out such that no cube is colliding with another. Around half of the time this works perfectly and the other half of the time Unity stops responding. public IEnumerator SpreadRooms(List rooms) { for(int i = 0;i(); yield return null; Debug.Log(rs.count); Debug.Log(rs.dir); while(rs.count > 0) { if(rs.dir == Vector3.zero) { rs.dir = new Vector3(Random.Range(-3f, 3f), 0, Random.Range(-3f, 3f)); Debug.Log("Adjusting " + rs.dir); } room.transform.position += rs.dir * 30 * Time.deltaTime; yield return null; } Debug.Log(i); Debug.Log(rooms.Count); } } According to the console it looks like the crash occurs in the while loop which made me think that it might be an infinite loop but I dont see why that would occur. Each cube has a dir for it to move in and none of them are zero including the ones that cause the crash. rs.count tracks the number of objects that the cube is colliding with. Ive been testing this with 50 objects and it typically crashes in the 40s for some reason but computer resources dont seem to be an issue.

Viewing all articles
Browse latest Browse all 2383

Trending Articles



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