Testing LevelGenerator

We went through some difficult coding recently. You might feel a bit uncomfortable still, but don't worry. The more time you spend coding, the more confidence you gain.

To test whether everything works correctly, we need to do some setup in the Scene:

  1. Create a new GameObject and call it LevelGenerator.
  2. Add a LevelGenerator Component to the LevelGenerator game object.
  3. Create a new game object and call it startPoint:
    Testing LevelGenerator
  4. Position the start point game object in the scene so that it is below and behind the Player game object. Thus, the first generated level piece will appear directly under the Player.
  5. Assign the LevelPieceBasic game object as the first element on the LevelPrefabs array.
  6. Assign the startPoint game object into the correct slot in the LevelGenerator component:
    Testing LevelGenerator
  7. Ready to test? Click on Play in Unity. If all went right, you should notice two initial level pieces generated. It should look more or less like this:
    Testing LevelGenerator

Congratulations! You just wrote a working part of a procedurally generated level. I get its not most exciting level yet. We will slowly get there; don't worry! Press S on the keyboard to start the game.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset