- Home /
Problems setting up a counter for room randomization.
To give a little clarity the game I'm making is a dungeon crawler (of sorts), but instead of having corridors and rooms you go from one room to another. Each room is its own scene, using scriptable objects I was able to create room randomization. For testing I created a boss room that ends the game after you beat the boss and exit through the door behind it, however because it was in the elements within the scenes scriptable object it is entirely possible to hit the boss room within the first couple of rooms. So I was trying to make a check so the boss room only appears after the player has moved through at least 10 rooms, this is what I have so far. public void LoadLevel(string level) { if (roomCount < 10) { SceneManager.LoadScene(level); } if (roomCount == 10) { SceneManager.LoadScene("BossRoom"); } } public void LoadRandomScene() { string level =roomList.randomScene [Random.Range (0,roomList.randomScene.Count)]; roomCount++; Debug.Log("Room: " + roomCount); LoadLevel(level); }
This was what was used to move through each scene, it worked but since I tried adding the room count it just loads the same room infinitely even after hitting 10 rooms. I have thoughts of what I'm doing wrong but I was hoping for a bit of help.
It is very simple my friend just do it like this
for example your boss is in roomCount 10
then why don't you just randomize the 1-9 roomCount
then after they're all executed then let roomCount 10
come out. hahahaha
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Writing a shader for a terrain? 0 Answers
Distribute terrain in zones 3 Answers
C# - Doesn't Unity support Expression Bodied Properties? 3 Answers