2D Roguelike 4 of 14 : Board Manager

2D Roguelike 4 of 14 : Board Manager


In this video we’re going to create our board manager script, which is going to procedurally generate our levels so that they’re different each time the player plays. We’re going to start by creating two empty scripts, our board manager and game manager scripts. We’ll choose Create – C# Script. Call the first one BoardManager. Call the second GameManager. We’ll also create an empty game object called GameManager. Let’s start by adding our level generation code to BoardManager. We’ll open it in MonoDevelop. The BoardManager script is going to lay out our randomly generated levels for us each time the player starts a new level based on the current level number. The first thing that we’re going to add is a namespace declaration using System. We’re going to do this so that we can use the serialisable attribute. Using serialisable just allows us to modify how variables will appear in the inspector and in the editor and to show and hide them using a fold out. We’re also going to add using Systems.Collections.Generic so that we can use lists. Finally we’re going to include using Random and we’re going to set that to equal UnityEngine.Random. We need to specify this because there’s a class called Random in both the system and UnityEngine namespaces. In our class we’re going to start by declaring a serialisable public class called Count. In Count we’re going to declare two public variables called Minimum and Maximum of the type int. We’re also going to include an assignment instructor for Count so that we can set the values of minimum and maximum when we declare a new count. We’re going to give it parameters Min and Max, which we’re going to use to set the values of minimum and maximum. Next we’re going to declare our variables. We’ll start with our public variables, the first two will be an integer for columns, and an integer for rose These will delineate the dimensions of our game board and will allow us to make our game board larger or smaller by changing them if we want to. In this case we’re going to initialise them each to 8 meaning we’re going to have an 8 by 8 game board. Next we’re going to use Count to specify a random range for how many walls we want to spawn in each level. In this case this means that we’ll have a minimum of 5 walls per level, and a maximum of 9 walls per level. We’re going to do the same for our Food items. Next we’re going to declare some variables to hold the prefabs that we’re going to spawn to make up our game board. We’re going to have a single game object called Exit because there’s only one exit object. For other objects we’re going to use a raise so that we can parse in multiple objects and then choose one of them that we want to spawn among the variations. Let’s start with floor tiles. We’ll also do the same for wallTiles, foodTiles, enemyTiles and our outerWallTiles. We’re going to fill each of these arrays with our different prefabs to choose between in the inspector. Next we’re going to declare a couple of private variables including a transform called boardHolder. BoardHolder is just something that we’re going to use to keep the hierarchy clean because we’re going to be spawning a lot of game objects we’re going to child them all to Board holder so that we can collapse them in the hierarchy and not fill our hierarchy with objects. We’re also going to declare a private list of vector3s called ‘gridPos’. We’re going to use this to track all of the different possible positions on our game board and to keep track of whether an object has been spawned in that position or not. Next we’re going to declare a function called InitialiseList that’s going to return Void. In InitialiseList we’re going to start by clearing our list of grid positions by calling the Clear function on our list. Next we’re going to use a pair of nested For loops to fill our list with each of the positions on our game board as a vector3, we’ll start with the X axis. So this first loop is going to run for as long as X is less than our number of columns. And then we’re going to do the same along the Y axis inside that. Inside that loop we’re going to add a new vector3 with our X and our Y values to our List grid positions. What we’re doing here is we’re creating a list of possible positions to place Walls, Enemies or Pickups. The reason that we’re looping from one to columns -1 is so that we can leave a border of floor tiles directly within the outer walls, this is going to mean that we’re not going to create a completely impassable level. Next we’re going to declare a new private function that’s going to return void called BoardSetup. We’re going to use BoardSetup to setup the outer wall and the floor of our game board. We’ll start by setting boardHolder to equal the transform of a new game object called Board. Next we’re going to use the same type of loop pattern to lay out the floor and the outer wall tiles. So we’re going to use another for loop along the X axis and along the Y axis. The reason that each of these loops is going to go from -1 to columns 1 or to rows 1 is because we’re building an edge around the active portion of the game board using the outer wall objects. Next we’re going to choose a floor tile at random from our array floor tiles and prepare to instantiate it. So what we’re doing here is we’re declaring a variable of the type GameObject called toInstantiate and setting it to equal an index in our array of game objects called floorTiles which we’re choosing randomly between 0 and the length of the array floor tiles. This means that we don’t have to pre-specify the length, we can just take the length and choose a number within that array. Next we’re going to check if we’re in one of the outer wall positions, and if so we’re going to choose an outer wall tile to instantiate. So we’re going to check if X is either equal to -1 or our value for columns, or Y is equal to -1 or our value for rows and if so we’re going to set to instantiate to a randomly chosen tile from our outer wall tiles array. Once we’ve chosen what tile we want to instantiate we’re actually going to instantiate it. So we’re going to declare a variable of the type GameObject called instance and then we’re going to assign that to the object that we’re instantiating. So we’re going to call Instantiate, parse in toInstantiate, the prefab that we chose, at a new vector3 which is going to be based on our current X and Y coordinates in the loop and we’re going to parse in 0 for the Z axis because we’re working in 2D. Quaternion.identity just means it’s going to be instantiated with no rotation and we’re going to cast it to a game object. With that done we’re going to set the parent of our newly instantiated game object to boardHolder. BoardSetup if going to lay out our outer wall tiles and our background of floor tiles. What we’re going to do next is we’re going to start writing some of the functions which are going to place the random objects on the game board like Walls, Enemies and Power ups. We’re going to decal re a new function that returns a vector3 called RandomPosition. In RandomPosition we’re going to declare an integer called randomIndex and generate a random number within a range for that. The range that we’re going to generate the number within is going to be between 0 and the number of positions stored in our gridPositions list, which we’re accessing using gridPositions.Count. Next we’re going to declare a vector3 called randomPositions and we’re going to set it to equal the gridPositions stored in our gridPositions list at our randomly selected index. To make sure that we don’t spawn two objects at the same location we’re going to remove that grid position from our list. We’re doing this by using the RemoveAt command and providing the index randomIndex. Next we’re going to return the value of randomPosition so that we can use it to spawn our object in a random location. Now that we’ve generated a random position from our list and made sure that it’s not a duplicate, we’re going to write a function to actually spawn our tiles at the random position that we’ve chosen. This is going to be called LayoutObjectAtRandom and it’s going to take 3 parameters. An array of game objects called tileArray, a minimum integer called and a maximum integer. The first thing that we’re going to do is that we’re going to declare an integer called objectCount and initialise it with a random value between minimum and maximum + 1. ObjectCount is going to control how many of a given object we’re going to spawn, for example the number of walls in a level. Next we’re going to write a for loop. We’re going to repeat the for loop for as long as i is less than our object count, meaning we’re going to spawn the number of objects specified by objectCount. We’re going to start by choosing a random position by calling our RandomPosition function. Next we’re going to choose a random tile from our array of game objects tileArray to spawn. We’re going to do this by generating a random number by using Random.Range between 0 and tileArray.length. We’re going to instantiate the tile that we’ve chosen at our random position. We can delete our start and update functions. And declare a new public function that returns void called SetupScene, which takes a parameter of the type int called Level. And notice that SetupScene is the single public function in this class. This is the one that is going to be called by the game manager when it’s time to actually setup the board. Within SetupScene the first thing that we’re going to do is call BoardSetup. Next we’re going to call initialiseList. We’re going to call LayoutObjectAtRandom and we’re going to parse in our array of wallTiles and also our minimum and our maximum wallCount values. Next we’re going to do the same for our foodTiles. Instead of generating a random number of enemies we’re going to generate a number of enemies based on the level number using MathF.Log to great a logarithmic difficulty progression. MathF.Log returns a float and so we’re going to cast that to an integer. This means that we’ll have one enemy at level two, two enemies at level four, three enemies at level eight, and that the difficulty will continually scale up as the player ascends in level. Now that we’ve got the number of enemies we want to spawn we’re going to lay them out using LayoutObjectAtRandom. Note that the minimum and maximum values in this case are the same because we’re not specifying a random range. Finally we’re going to instantiate the exit. The exit is always going to be placed in the same place and is always going to be the same object so we’re just going to call Instantiate and parse in the prefab Exit. The exit is always going to be in the upper right corner of the level, which is why we’re using columns -1 and rows -1 and this means that if we choose to resize our game board the exit will still be placed correctly. Let’s save our script. Now that we’ve got our level generation code written in our Board Manager in the next video we’re going to start writing our Game Manager and setup the Game Manager prefab. Subtitles by the Amara.org community

100 thoughts on “2D Roguelike 4 of 14 : Board Manager

  1. Hi, I don't get why we don't set the transform to board for instance coming in LayoutObjectAtRandom and for the exit ?

  2. Comment Section: "This sucks! I should be able to learn how to code in a few hours!! I wanna make my game now! Give me my instant gratification!"

  3. I got two questions:
    1 – I dont know if i miss something but sometimes he not even type a single letter and the code auto fills in. Is it because of his program? I am using MVS but only because it's auto start.
    2 – I completet the UFO tutorial and now doing this one. Now he is talking/typing/go on so fast that its hard to follow. Is there a Tutorial that i should do second?

    ps: Sorry for my bad English, i hope somebody will understand what i am try to say/ask 🙂

  4. My constructive feedback for this whole 2D Roguelike tutorial is that it would be much more enjoyable if we could actually test what we have done at the end of every video.

    It is so frustrating to set up game objects and write scripts without having any interaction with the final product. This is not how software development (and why not game development) works.

  5. What determines whether a GameObject is drawn in Unity? Is this only done when an object is Instantiated? If not, then wouldn't all 'toInstantiate' objects be drawn (at default position (0, 0, 0), as well as the instance objects?

  6. it is better to instantiate individual tiles instead of making a prefab of the "level" and make several level prefabs?

  7. Good video. i've spent over 2 hours on this 15 min video, typing the code, trying to understand it and looking up the classes in the docs 🙂

  8. Good video, thnx to author.
    Also I found a small mistake in subtitles at 2:33: "an integer for rose" when the correct is "an integer for rows".

  9. While copying he's code I made comments with // in each line, to keep track of what each variable would be used for, that helped a bunch

  10. Matt, for future videos please avoid typing scripts on the bottom part of the screen. It becomes very difficult to comprehend what you typed while having Youtube paused. That happened from around 11:20 to the end of the video.

    Besides, thank you, great tutorial!

  11. I had to stop watching this video series. I literally turned my head away, covered my eyes with my hands, and took a couple of deep breaths while watching this video.

    Using an out parameter so you can "return more than one value"? Consistently using the idiomatic style of another language?

    I think the worst was the complete fail on naming variables.

  12. For those who find the pace of this tutorial fast or do not understand the code completely, i will advise (if not already done) to complete the tutorials for:
    1- Space Shooter
    2- Survival Shooter
    3- Tanks
    After you've completed those three you'll find that this tutorial will not spoon feed you but actually let you learn stuff on your own with an amazing pace. Im a beginner at Unity and after completing the other three tutorials i've found this one pretty amazing. I hope after i've completed all these tutorials i will be able to create and publish games of my own. Plus its amazing what these guys at Unity are doing, cheers !!

  13. For some odd reason I had to set my exit column (Last line with text) to 7 rather than -1 as shown in the video anyone have any ideas about that.

  14. Can anyone explain why the tiles are instantiated at X,Y of 1,1 and 1,2 and 1,3 etc… How is it that they are exactly even values. I do not know where this is explained in the videos. How do I know what location to put my objects at?

  15. I found the speed to be just fine. I have never used Unity before. What I would suggest is people first watch the video a couple of times to understand the logic behind the code, and then actually write the code by slowing down the video in settings to half or a quarter of the speed. Good video. Very pleased with what I am learning. Thank you Unity Team.

  16. your BoardSetup() method is so over complicated, it's sooo bad. just do if(){ create wall } else{ create floor }. not all that object passing and transforming…. i know it seems kind of elegant, but it's really inefficient. plus, if you can understand all the crap your doing…. you don't even need this tutorial…….

  17. Thank you so much for this tutorials. You are doing such a great job. Its really cool to watch professional proper coding.

  18. >sees a class in a class
    thinks "hmm, I wonder if that bothers anyone else?"
    >opens comment section



    >slowly walks away from comments section

  19. Great tutorial, thanks! I think people complaining about the jump in pace/difficulty have issues with the syntax more than the content. I'm fairly familiar with java (admittedly not c#) syntax, and I didn't think the procedural generation introduced anything conceptually too difficult. Any confusing areas were explained just fine in the video.

  20. when I try

    GameObject toInstantiate = floorTiles[Random.Range (0, floorTiles.Length)];

    I get a parser error: an embedded statement may not be a declaration or labeled statement

  21. I was starting to feel terrible for not being able to keep the pace while having to constantly stop the video.
    But then I saw the comments and realised this was a general problem.
    Also the video is very funny at 0.5 speed.

  22. So after I read the comments I thought that he just wrote the code really quick and didn't say shit. No he literally explained every line. I guess people just wanted to be coding experts after one video….

    FYI I basically have no coding experience and this was fine for me. I mean yeah I probably couldn't make my own game after just this video but no shit.

    However, I would've liked to know I'd need another program , monodevelop, and how to make a new script…
    like I downloaded this and hit new and there was a lot of options.

  23. This was actually really poorly done, the parts that made more sense were explained more than the confusing ones…

  24. Well, I was watching this on one screen and writing code on another, so I managed to follow without pausing the video, but it did require additional 10 minutes to reread all the code and understand in clearly afterwards 🙂 Nevertheless, it is a lot easier to pause a video than making it 1.5 speed and hearing blurred voices. Good job!

  25. I agree with Kapp. This is an intermediate tutorial, it assumes you're a programmer to some degree. It provies you with a foundation and is well-explained, and yet some people call it linear?

    Wake up – you think a full-time developer gets micro-managed and told how to do things? No. S/he figres it out. Engage your brains people you're all smart, set debug points and learn the flow of the program – nobody can do that for you.

  26. For everyone saying thar this is too fast, or that is not really a tutorial since "he didn't explain all that code".
    Disclaimer: I am a programmer (but no even on C#) and a Unity noob.

    I still agree that this tutorial is at intermediate level and very well done. The code was simple and even had animations explaining "why this loop should be like this, and this should be this way".
    What almost everyone is saying feels bad to me for the professionalism used on this series.
    If you didn't understand any of that code, that's totally fine, just open your mind that maybe this is not yet for your level and you should need to start smaller (which is also totally fine, not a shame as everyone had to do that once), instead of blaming it for not teaching what it expects you already understand.

  27. For all the people saying this isn't a real tutorial I'm not entirely sure I agree. He comes right out at the beginning and says it is meant for intermediate users and expects a degree of understanding how the engine and the code works prior to following the tutorial. I came here with prior programming experience just trying to get some ideas for implementing a roguelike in unity and it worked fine for me. I can understand how some people would find it difficult to follow but if you found it difficult to follow you aren't an intermediate user and this tutorial wasn't made for you. There are plenty of beginner tutorials (I recommend Quill18Creates or any unity official tutorials labeled beginner) for people who cannot follow this one. I started there and worked my way up and would advise that you do as well. Cheers.

  28. I think the problem with this tutorial is the fact that it isn't explained WHY it's being done this particular way. The thought process for getting a solution is just as important as learning the code and the engine. Making mistakes and learning from them is such a useful thing that is missed out here. An effective tutorial would step through the process of "We want to generate a tile grid. What ways can we think of to get this done?" and build it up from there, making mistakes and correcting them, instead of just speeding through the code.

  29. when i read all the comments about the tutorial being too fast i took that as a challenge, i can almost type fast enough, so that is no problem, but i noticed that with tutorials like ball game and space shooter i had a lot of time for guessing the next step and understanding, which i think is an incredibly valuable part in learning a new craft.

  30. XD Watch the segments of coding first and understand what he is doing. Then pause the video and type the code. Otherwise you won't understand the reasoning and logic of the steps. Having 2 monitors is also really productive. People are mentioning that the tutorial is too fast, and some might say it is too fast because you don't have the experience of Object orientated programming or C#/unity blah blah…but I'm familiar with everything he is doing in the coding side and it is still very fast trying to type, listen, and understand the reasoning at the same time (I type around 80 wpm). Make the use of the pause and rewind, you'll need it. There is also the playback speed option is settings that you can reduce. Good Luck!

  31. Great tutorial. I was skimming the comments to see if there was a reason for Vector3 instead of Vector2, but found a lot of people just complaining about the video. I've been a PHP programmer for probably around ten years now, this is the first series that I found the pacing was great. Did I have to pause now and then, yes but it's way better than having to wait for the instructor to catch up to me or explain to me what a float was or how to concat a string. If you have trouble with this video you either need to keep going through the beginner tutorials or you need to take a couple classes on programming.

  32. I don't understand, my script was full of bug so I tried to copy past everything in the one in the completed folder but again errors, but not the same and the strangest thing is that when I start the debug in the original scrpit it says that nothing is wrong

  33. this tutorial is horrible however thank u for ur effort but its so hard to follow up specially that this is my first 2D tutorial for unity

  34. could just skip the 2nd GameObject creation and go straight to toInstantiate = Instantiate(toInstantiate… etc) instead also not really understanding the reason why "as GameObject" is used when it returns a GameObject to begin with.

  35. So how come everything is public in our Count class? No need for Encapsulation?
    I am trying to learn to write clean code, but I keep encountering contradicting practices among different programmers.
    Was [SerializeField] available back in Unity 4.6?

  36. I did have to pause several times, but damn this was the pace I needed, I was tired hearing "By the way in unity you can add game objects in 3 different ways, first in the menu…". Looking forward to and advanced tutorial.

  37. How can I achieve the same except without leaving a one tile spacing around the board to ensure the exit is always reachable? I mean, I still want the exit reachable but I don’t want a walkable path around a procedurally generated maze.

  38. for(int x = 1; x &lt; columns-1; x++) can anyone explain to me why the x &lt; line? Instead of for(int x = 1; x < columns-1; x++)

    Edit : I see in the video he uses my second example, while in the code on the unity site they use my first example

  39. When I make GameManager.cs, the icon changes from the normal "C# on white paper" icon to a sort of grey cog/gear icon. Does anyone else have this (I'm using Unity 2018.2)? Is it a bug or a feature? It only happens if I spell it like this, e.g. Game_Manager and GameManager1 do not produce this effect.

  40. Had to go through all of my code just to find out why it crashed on me xD One little x instead of a y xD

  41. well it's going to take me some time to finish this series. I think I am going to do 1 video a day after seeing how much code i have to go through from now on.

  42. so far so good.
    but what i dont get is that ive written the code exactly like yours but visual studio tells me that the methods we call in SetupScene() are not existing in the current context.
    why is that and how do i fix it?

  43. Great series so far, just learning to apply my C# knowledge to game development and this makes all the sense. If it doesn't, you should probably be watching C# tutorials instead of Unity tutorials for now. You wouldn't watch a tutorial on digitalizing art to learn how to draw, this is the same deal. Learning Unity and learning a coding language are examples of two entirely separate fields that converge to help create the bigger field of game development.

  44. I was typing along with your video and towards the end, I couldn't even remember the variable I was typing as IntelliSense showed it to me. I was like, hmm, is this a built-in function or something? Why was LayoutObjectAtRandom showing in IntelliSense? I paused the video and looked at my code and there it is. hahaha

  45. Watching in 0.75 speed and I still had to pause a couple of times. That's just crazy

    This is super fast, but take a look at the fully completed script within the tutorial. There are comments for every line. It is really helpful to understand the logic of what he is typing

  46. People need to stop complaining about difficulty. If you don't know how to do basic programming, then why are you here? Stop trying to run before you've even crawled.

    Pacing concerns are valid.

  47. Wow I loved the coding in this one. The brain is like a muscle after all, you can only get it stronger by incremently increasing weight to your workouts. The last tutorials were pretty basic and easy (but fun) but my brain is enjoying being challenged in this one. Thanks!

  48. Aside from the fact that my C# skills are obviously severely lacking, my biggest beef with this tutorial is that it was far too *linear*. I would have appreciated bouncing around in the code with justifications (to be fair, maybe he did that after the basic setup; he lost me when he started declaring a shit ton of variables with no discussion on the logic behind them for awhile).

  49. This video, even though it is advertised as being an intermediate video is still too quick. Even as someone who works in c# every day, I have a real issue with someone writing code without actually explaining whats going on. How else do you comment it?

  50. Hmmm been looking through the code, and I'm probably missing something small, but the floor won't generate when I press play. Looked over my BoardSetup function: and that looks fine
    `
    void BoardSetup ()
    {
    boardHolder = new GameObject ("Board").transform;
    for (int x = -1; x < columns + 1; x++)
    {
    for (int y = -1; y < rows + 1; y++)
    {
    GameObject toInstantiate = floorTiles[Random.Range (0, floorTiles.Length)];
    if (x == -1 || x == columns || y == -1 || y == rows)
    {
    toInstantiate = outerWallTiles[Random.Range(0, outerWallTiles.Length)];
    GameObject instance = Instantiate(toInstantiate, new Vector3 (x,y,0f), Quaternion.identity) as GameObject;
    instance.transform.SetParent(boardHolder);
    }
    }
    }
    }
    `
    And SetupScene:
    `
    public void SetupScene(int level)
    {
    BoardSetup ();
    InitialiseList ();
    LayoutObjectAtRandom(wallTiles, wallCount.minimum, wallCount.maximum);
    LayoutObjectAtRandom(foodTiles, foodCount.minimum, foodCount.maximum);
    int enemyCount = (int)Mathf.Log(level, 2f);
    LayoutObjectAtRandom(enemyTiles, enemyCount, enemyCount);
    Instantiate(exit, new Vector3(columns – 1, rows – 1, 0), Quaternion.identity);
    }
    `
    Maybe I'm missing an in-editor step?

  51. Who exactly is the audience of this video? Why was it made? At this speed, you explanation isn't even as helpful as downloading the source code and reading the copious amounts of comments. So, its not for beginners, and its too easy to be for experts. Its not explaining anything that an intermediate wouldn't understand better by looking at the code at his own pace…why did u waste your time making this? Not even explaining things like Quaternion.

  52. I've done all the other tutorials then get to this one, although I do follow some of the code and using unity is easy, slow down even on the typing, i'm tying to type the code out my self for good practice AND because I want to learn but you need to slow the pace down for us to actually type without having to pause, start pause start. Glad i wasn't the only one struggling with this.

  53. Worst Learning Tutorials of all by now. Not that i couldn't follow the logic, it's just extremely annoying to hold up with that speed and write along while trying to learn something.
    Total turnoff for newcomers.

  54. I have decent knowledge in OOP and stuff, and i understood everything he said but i'm just not good at creating my own code. So is okay if i keep going or should i improve in coding or something? will i just improve overtime?

  55. I love the pace of the video. I love pausing the vid to catch up, or even repeat some sections, it makes me feel like the video has a lot more practice and knowledge built in it behind those 14 min, maybe a 30 min video, but condensed.

    On another note though. Unity tells me there's a problem with my script and its "[Serializable]" line
    any clue what's going on?

  56. What's happening at line:
    LayoutObjectAtRandom(enemyTiles, enemyCount, enemyCount);
    There's no randomness here, we are passing the same number instead of a minimum and maximum range?

  57. keep getting "no monobehaviour" error even when I add completed script to the object. I'm guessing I NEED the "namespace Completed" crap that isn't shown in this tutorial?

  58. Fantastic tutorial here, thank you so much!

    One thing i cannot stop wondering is, wouldn't it be nicer to use a struct instead of a class for the Count?

  59. Is this a good practice to instantiate and child the instantiated prefab to a parent right away?

    // Instantiate<GameObject>(toInstantiate, new Vector3(x, y, 0f), Quaternion.identity, boardHolder);

  60. Summary of the functions:
    InitialiseList() => Simply creating a List of positions of size 6×6, in the middle of the board. This List will be used to spawn objects at these positions.

    BoardSetup() => Creates floor tiles ( or outer wall tiles if in border) in a 10×10 grid ( game is 8×8 but due to border total is 10×10). Also setting all instantiated objects' parent as the boardHolder.

    RandomPosition() => Chooses a random item from the List created in IntialiseList(). Also, removes that item from list so it's not used again.

    LayoutObjectAtRandom() => Instantiate random tiles from the tile array that you pass, and the number of instantiated objects is between min and max values, that was also passed.

  61. well… i ve been following the tutorial, after seeing people complaining in the comments dont know what to do, can anyone please recommend me some good unity tutorial?

  62. Overall great tutorial and I really really like this series. However, this part of the tutorial is poorly done because it is obvious that the instructor is just copying code from top to bottom from an already completed file. The logical flow of how the code was created is lost.

    For example, the instructor writes out the InitialiseList() function and then immediately writes the BoardSetup() function. BoardSetup and InitialiseList are completely unrelated to each other. Neither of them are used anywhere else at this point. So why write them now? Furthermore, the entire 14 minute video writes a whole blurb of code without once testing or demonstrating (in the editor) any piece of it. This is not friendly to the viewers who are trying to learn, as voiced by some of the comments.

    Suggested Solution: Write the code in a logical and iterative way, and demonstrate the code working in the editor. For example:

    1. First have the Start() function call SetupScene(level: 8). That way we can test the code as we go along.

    public void Start()
    {
    SetupScene(8);
    }

    2. In SetupScene, we need to set up the board. So lets write the BoardSetup() function.

    public void SetupScene(int level)

    {

    BoardSetup();

    }

    3. To setup the board, we need a few variables: floor tiles, wall tiles, etc. Set the tiles in the inspector and run the project. We can now see that the board is now set with floors and walls.

    4. Next we need to add some random walls. We need a list to store random positions:

    private List<Vector3> gridPositions = new List<Vector3>()

    Lets write a new function: InitialiseList(), which will initialize the random gridPositions list.

    public void SetupScene(int level)
    {

    BoardSetup();

    InitializeList();
    }

    5. Now that we have a list of random positions, lets write a new function: LayoutObjectAtRandom that will use the gridPositions we just made.

    6. etc.

    I hope this helps with future tutorials.

  63. alguien sabe porque cuando creo el script de "game manager" este toma un icono de engranaje, pero cuando lo copio de el juego terminado sale norma?

  64. learning in fast forward haha!

    great tutorials! (a little bit of more thorough explanation wouldn't hurt tho)

  65. I am an almost noob in programming from Russia and while this DEFINITELY not easy for the complete beginner, it was not impossible. If you try hard enough you can wrap your head around it, and while this does need a tiny little bit expansive commentary it was at the end clear and logical. Thank you for the effort and video!

Leave a Reply

Your email address will not be published. Required fields are marked *