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:
Create a new
GameObject
and call itLevelGenerator
.Add a
LevelGenerator
Component to theLevelGenerator
game object.Create a new game object and call it
startPoint
: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 thePlayer
.Assign the
LevelPieceBasic
game object as the first element on theLevelPrefabs
array.Assign the
startPoint
game object into the correct slot in theLevelGenerator
component: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:
Congratulations! You just wrote a working part of a procedurally...