Documentation
Overview
Square Move "Endless Runner Game Template" is a powerful elegant approach to offering a template solution for game creators to place their artworks and additional game code on top of.
The “Endless Runner” style has the player running forward along an endless path where the obstacles after certain distances start to evolve. All Obstacles are grouped into something we call “Stages”. At the beginning of the level load, all Stages are loaded into memory and are draw from and placed at the correct location as the player makes their way forward.
So for example, the player starts running and gets 10 meters into the level. The Stage spawning algorithm finds all the Stages that can spawn at level 1 or less and then places a Stage 20 meters in front of the player so they will start to see it momentarily.
As the player runs along and increase the distance in how far they have journeyed, the Stage system increases the level every X distance. So at 10 meters in, the player is at level 1 but at 100 meters in the player might be at level 2. 200 meters in the player might be at level 3. 300 meters is level 4 and so on.
With the unique dynamic structure of each Stage you can not only advise the stage when it is to start appearing ( show when the player reaches level 5 ), you can also add objects to that particular scene and tell them specifically to only show up after level 6 or level 10 or whatever level you choose. This means that you can setup a simple Stage to begin with that will show in the early parts of the game and then later on have that same Stage change itself to get hard and hard.
You can also just make an extremely hard Stage and tell it not to show till level 20 but the former gives a lot more flexibility and replay ability to each Stage.
ADDED BONUSES: There is also a full notification system that you can see activate when menu buttons are pressed. There is a sound on and off button in the menu with a full Sound Manager system in the game PLUS a bunch of other items that have not been mentioned in great detail below like PlayerPref Encryption so people can't just change your settings via a text file, iTween transitions that work on objects and UI and a lot more.
What you can see in the above image is 4 Stages that have been spawned already. These Stages are unique and we have shown this down the right hand-side with their unique ID's. In this example the player has run 200 meters so each one of these Stages have been told they can spawn after the player reaches 200 meters (or the player reaches level 4 ... 4 x 50 meters = 200 meters).
How they are spawned is the Spawning system looks through all the Stages that it can possibly spawn at this time and checks it hasn't been previously spawned lately. If all checks out it places the Stage into position to be used.
Stages
We have included a MASSIVE 61 Stages for you to use in your games or as samples on what you can do!!
A Stage can contain any objects you wish. Animated, Pathing, Moving, Particles, Rotating, Scaling ... whatever you wish. All you need to do is duplicate one of the Stage prefabs that already exist and start adding your objects under the root object with the Stage script on it.
YELLOW LINE (minWaitDistIn) -> This is the distance this Stage will be positioned away from the previous spawned Stage
RED LINE (minWaitDistOut) -> This is the distance the player must run past this Stage before the next Stage is spawned
GREEN LINE ( unloadDistance) -> This is the distance the player must run past this Stage before it is unloaded and placed back in the pool of Stages to be used again
NOTE: All Stages are pre-loaded so there is no lag (spawning / instantiation) during gameplay. There are "Pools" of Stages to draw from.
Objects
There are many different kinds of objects you can add to your Stages. Static Objects, Objects that Path, Rotating Objects, Circles and Clusters of Objects and more.
The basic "static" object like a wall uses the "ObjBase.cs" script. This script has a bool that tells the object whether the player can touch it or not (true / false) and the "Level to Show" value tells the Stage Spawning system when this object should be active throughout the game. If it is set to 1 then it is active from level 1, if it is set to 10 then it will not become active till the player has run the distance to make it to level 10.
You can add rotating objects to your Stage by adding the "ObjRotator.cs" script.
You can add pathing objects to your Stage by adding the "ObjPathing.cs" script. The Node Count is how many sections of path (or nodes) the object will traverse. You can adjust the path directly in the Unity Editor for each object and then just save the Stage (or Object) prefab out when you are done.
You can add cluster objects that spin around and form circles to your Stage by adding the "ObjCluster.cs" script. The "Objs To Spawn" is the prefab that you want spawned in this cluster. You can add as many prefabs as you like and the ObjCluster script will random spawn from the list you provide. The amount of objects that are spawned into the cluster is handled by the "Objs To Spawn Count". The "Min Scale" and "Max Scale" determines the random size of each spawned object. "Real Time Positioning" enabled will see the cluster of objects rotate and update their positions. "Radius" is the size of the circle of the objects. "Rotation Speed" is the speed in which the circle will rotate and the "Rotation Axis" will determine what axis the clusters is rotated around.
You can also add pickups to your game like "Stars". All you need to do is drop in a gameobject with the script "StageSpawnContainer.cs" and select the "Star" from the Obj Type menu and when the Stage is spawned a Star will be put in the positoin of the gameobject with the StageSpawnContainer script. You can also spawn moving characters this way. Just change the Obj Type to "Character_1" to see an example of this or view some of the other stages provided in the package.
Ground
The ground will dynamically be repositioned as the player moves along. Once the player goes past a second of Ground and it is out of the view of the screen that the player can see it gets repositioned all the way to the front of the line again to be reused. You can add to or change any of the ground objects to repeat whatever style you wish.
Player Cubes - Powerups!
There are different types of Cubes we have created for this template. There is a BLUE cube which allows the player to shrink as they level-up that cube. There is a RED (FAST) cube that speeds up the pace of the game as they level-up that cube. There is a GREEN (MAGI) cube that as the player gets close to the stars they are pulled towards the player to make it easier for the player to pickup the stars. This pulling power increases as the player levels up that cube. There is a PURPLE (ROTA) cube that allows the player to slow down the speed by moving quickly from side to side. Again, all powerups get more powerful as the player levels up that cube.
Player
The player is controlled by the "Player.cs" script. Starting a the top, the "Cube Level Test" allows you to set the upgrade level for the players cube to determine how good the cube powerups will be if the player gets to that level. "Direction" is the facing of the player. Currently it is set to look upwards but you can adjust this setting along with the "Main Camera -> MousePos" object (in the Hierachy) and have the player run down, left or right. "Speed Ratio Max" and "Speed Ratio Min" determines the speed in which the player travels at. Setting these both the same will make sure the speed is always consistant. "Rot Speed" determines how fast the cube will turn to face the mouse (or finger) position on screen. "WorldEdgeLeft" and "WorldEdgeRight" are the values to set so that the player can not move left or right beyond these max world positions. "Mouse Pos Obj" is the object the player follows when input (like mouse down or finger down) is active. The rest is mainly to do with the cubes themselves.
Project View
The Project consists of the following structure
The folders that require explanation are the projects and scripts. Everything else is self-explanatory.
Prefabs
Stages are groups of objects that form the level components.
Characters are any object in the world that is going to path towards the player.
Objects are any objects that can be used within a Stage.
PFX are objects that will be used to spawn particle effects.
Scripts
Characters are any object in the world that is going to path towards something. Characters will have the "CharacterBase.cs" script applied to them. There is an example cube in the "Characters" folder that is used in the template.
The "Game.cs" script holds all the Stage prefabs to spawn them into the world on initialisation. "Debug Crash Off" allows the player to run forever without crashing into anything (good for testing). "Level" is the level that the player starts on and processes. "Level Dist Inc" is the amount of meters the player has to travel for the "Level" to increase. "Level Current Dist" is the amount of distance the player has travelled (it is public / exposed so you can easily see it). "Speed" is how fast the player will travel through the world and is used in conjunction with the Player scripts Speed Ratio values. "Stage Test" allows you to place a Stage prefab in that position and run the game so that only that particular Stage will be spawned (very good for testing, but don't forget to remove it!). "Stage Prefabs" are the place you need to add all your Stages you want within the game, currently we have added 61 Stages to the game for you to look at how they work and copy. "Spawn Pos" is the gameobject in the world where all Stages will spawn from. This gameobject is found under the "Main Camera" object in the Hierarchy and moves with the player. "Character 1Prefabs" are lists of characters that will be spawned in a pool of characters to be used in "Stage Spawn Containers" when the "Obj Type" is selected as "Character_1". "Star Prefabs" are lists of Stars that will be spawned in a pool of stars to be used in "Stage Spawn Containers" when the "Obj Type" is selected as "STAR". Both the "Character 1Spawn Amount" and the "Star Spawn Amount" should remain high so that the pool doesn't empty and has to wait for another star to become unused to use it on another Stage.
The "UIInGameMenu.cs script is very straight forward (and uses Unity's new GUI system) and allows players to select their cube, play again and has hooks into the code to allow you to add your apps Rating link to take people to the app stores (iOS, Android and Desktop) as well as a High Scores and Upgrades button to hook into.
Support
Like always if you have any problems please contact us via our support form on our website at www.wireddevelopments.com