For today's post, I'll discuss the system involved with generating columns for the player to jump between.
First, let's talk about the way each column works. A column involves three game objects, a game object that represents the top column, another that represents the bottom column, and the last one which represents the "Pass Zone".
As you imagine, each of the game object that represents a column will have a box collider associated with them. The "Pass Zone" also contains a box collider and allows the game to know when a player has successfully passed an obstacle. To make the column scroll across the screen, I create a ColumnScroll.cs script that looks like the following:
Now that we have one column in place, we need a system to generate them procedurally so the player has a constant stream of columns to pass through. So in the scene hierarchy, I create a game object with a script called ColumnCreator.cs
This script is fairly simple as you noticed. The core of the logic lies in the coroutine where the system continuously spawn a column at a given spawn point every spawnInterval. Lastly, given our previous post about event listener, I create a start game event and when the start game event is called, the main game class can call the StartSpawn method to begin spawning of the columns.
No comments:
Post a Comment