2. Creating Your Own Game

The full process to creating your own game from an empty map

The easiest way to do this would be to find a template that most closely suits the game you’re going to create. For example, if you know your player will have lane restricted movement then starting with the RoadRunner template will allow you to start with the main logic already implemented.

You can then refine the Pawn, Obstacle and level spawning logic to meet your exact requirements.

If you’d like to start completely from scratch though I’ll run through the process of setting up all the actors and components you’ll need to get going.

To begin I’d always recommend setting up a sensible folder structure to make it easy to manage your project while also keeping the important base classes of this plugin readily available.

So I’ll create a new folder in the root content directory and call it NewGame. Inside of NewGame I’ll also create a Blueprints and Maps folder.

Create a new empty map and save it in the maps folder, I’ve called my NewGameMap.

At the moment the default map for the project is the menu map, this allows you to easily start the project and select a template to test. For your game, you may want to stick with a similar structure but remove the template menu and replace it with something like the usual Play/Options/Quit main menu, splash screen etc.

So we can leave the project defaults as they are. What we need now is a GameMode class to control the game flow of our NewGame template.

Inside of the Blueprints folder right-click and select "Create Blueprint". Go to the extended blueprint search and look for BP_GameModeBase, this is intended to be the base class for all in-game logic.

Select this and name your new GameMode. I’ve gone for BP_GameModeNewGame.

For the player pawn, I’m going to go for a lane-based game mode for this example, so inside of BP_GameModeNewGame I’ll set the default pawn to be BP_PlayerRoadRunner.

Now navigate to the Blueprints dropdown, select world override, select GameModeBase class and choose BP_GameModeNewGame.

This means that whenever this map is loaded we’ll force it to use our custom GameMode and if we press play now we’ll be controlling the RoadRunnerPawn. We’re still missing a few actors required for gameplay logic so you’ll get some errors at this stage that we’ll correct now.

The first warning message displayed here is that all levels require exactly one LevelManager actor in the world. So let’s go to the EndlessRunnerCreator->Common Assets->Blueprints->Game and drag the BP_LevelManagerBase into the world.

This class will handle a lot of the logic during runtime and also has most of the game type-specific values exposed in the details panel.

I’ve created a custom billboard to make it easy to locate and select for quick changes in the editor.

The main values we want to change to get the basics of a game implemented will be the "Level Speeds" values and the "Bounds".

The Level Speeds will control how fast the level pieces, obstacles and pickups will move and the Bounds will control when these classes go out of bounds, where to hide them and when to recycle and bring the components of a level back into play.

  • InitialSpeed will control the starting speed of the level pieces.

  • MaxSpeed is the cap at which the level pieces will stop increasing in speed.

  • Speed Acceleration is the speed increments at which the level speeds up as long as MaxSpeed is set to be higher than InitialSpeed.

  • If you want a level to stay at a constant speed you can leave MaxSpeed to be the same or lower than InitialSpeed or leave SpeedAcceleration set to 0.

  • LevelMovementDirection is the direction the level pieces will scroll. Positive X is forward, negative is backwards, this is usually towards the player and the way most Game Types will be set up.

    • You can take a look into the VerticalRunner template to see how you can use this for vertical movement.

    • NOTE: the Y-axis should not be used as this has been excluded from the update logic to simplify the update logic.

I’ve filled these with some arbitrary values to get started and you can play around with any speeds you’d like but for my example I’ll use an InitialSpeed of 500, a MaxSpeed of 2000 and quick AccelerationSpeed of 100 to see a quick increase, usually something in the double digits feels a bit better.

Finally I’ve set the MoveDirection to -1 on the X-axis.

Next we want to set our Bounds details. All of these have widgets and visualisations in the level that can be found by default on the LevelManager Billboard.

This will help you drag the bounding boxes into place and scale them as required.

In this case I’ll move the “DisabledPooledObjectLocation” far behind the player start in the X-axis to ensure that when object pooling happens, the out of bounds objects are not seen.

I’ll then move the “OutOfBoundsBoxLocation” behind the player start to mid way between the player and the “PooledObjectLocation”. This isn’t an exact requirement, we just need the “OutOfBoundsBoxLocation” to be outside of the camera view so we don’t see level objects pop out of existence.

Next create a static camera that will look towards the PlayerStart and set this to be the default camera.

Remove the default floor as we won’t be needing that.

Next we want a spawner class to handle creating our level floor. For this navigate to EndlessRunnerCreator->Common Assets->Blueprints->Spawning and drag a BP_SpawnerLevelPieceBase

Ensure this is centered on the Y-axis and lower than the PlayerStart object to ensure the floors will spawn below the player.

With our Level Spawner selected, we want to press the plus next to the SpawnActorType so we can provide a type of floor to spawn. For this example, search for and select the BP_LevelPieceRoadRunner class.

Provide a value in the “ActorsRequired” value, this will control how many objects to spawn by default. You might need to test and update this value depending on your camera setup to fill the screen. For me 5 is enough here.

SpawnNewActorsIfRequired” will allow the game to spawn new poolable objects of the selected type if more are going through the level bounds collider than are currently pooled and available to reuse.

Tick “MovingChildren” to confirm that the classes spawned by this LevelSpawner will need to move. You can disable this for any case where you might not need or want an object to move when spawned.

Finally you can use the editor utility buttons to visualise and clear your spawned objects. These are intended to help get an idea of whether your settings will set the level as intended whilst still in the editor.

As an example, press the “Editor Visualise Level” button to check the floor spawner fills the screen with floor actors.

If you press play now you have the basics of a working level. One thing that can be fixed is the screen hint for the controls is currently displaying a hint for a different game type.

To resolve this we can select the Level Manager class and under the GameTypeSettings section change the GameType to RoadRunner.

This is an Enum created to help manage game type specific details like the hints that will be displayed. You can look into this class further, add your own game types to the enum and drive the linked logic to them.

This now accurately reflects how you control this player type for the current game setup.

The last thing we need for a complete game loop is an obstacle to avoid.

Return again to EndlessRunnerCreator->Common Assets->Blueprints->Spawning and this time drag in a BP_SpawnerBase, in this example I’ll drag in three, one for each lane.

You can see again the billboard which in this case has defaulted correctly to the obstacle icon, but you can use this option and change it to other types and the billboard will automatically update.

These are the values I’ve chosen for the obstacle spawners.

The SpawnDelays control the minimum and maximum value that can be used for a random timer for the spawning logic. The AbsoluteLowest for the min and max delays allow the ranges to be lowered over time to increase difficulty but never get below a set minimum value.

For the Spawner Options I’ve reused the BP_ObstacleRoadRunner class as the obstacle type.

5 actors should be fine to start and I’ve allowed the object pool to expand if needed using the SpawnNewActorsIfRequired boolean.

And finally checked MovingChildren to confirm that these obstacles do need to move.

And that’s it, if you now press play your game will start, obstacles will start spawning after your set time and if you hit one of the obstacles you’ll be met with the Game Over screen.

These are just the very basic steps of how to create a game from an empty level and more details will be coming about each individual class and how to create your own obstacles, spawners, pickups and more.

Last updated