Mathematics plays a central role in constructing games. Whether positioning objects in two- or three-dimensional space, determining if one character is looking at another, or how light should reflect off a particular surface, mathematics underpins many mechanics in modern gameplay. While many mathematical concepts used in games can seem advanced and intimidating, some allow for a more user-friendly introduction.
Introductory Concepts
Placing objects on a two-dimensional grid within a three-dimensional world space is a central mechanic used in most turn-based strategy and tactic games. The mathematics involved is simpler than some other mathematics-based video game mechanics, but is central to creating many of the most popular games made.
Randomness is an important tool in a game designer's toolbox. Randomness provides a mechanism to create a variety of gameplay experiences without predefining a large number of deterministic experiences and tracking all of them simultaneously. One of the keys to randomness is to provide a reasonable amount of variety while still controlling enough factors that things do not become chaotic. This requires putting up boundaries on how random or ordered things can become.
Learning Through Experience
In this tutorial, you will learn how to implement core mechanics of a turn-based board game in UEFN with Verse. This game is published as a Fortnite island named Coordinate Battle! with island code 6259-2097-7759.
Overview of the Gameplay
The game is a two-player, turn-based board game. Each player's board is a 5 x 5 grid with five randomly placed and hidden pawns. A player has a direct view of the enemy board with hidden pawns, and a smaller view of their own board in the upper-left corner of their screen.
Players take turns choosing a coordinate on the opponent's board.
Once a player chooses a coordinate, they have two options:
Reveal enemy pawns within a certain radius of the chosen location, or
Attack a location and, potentially, destroy the enemy's hidden pawns.
The first player to destroy all five of the enemy's pawns wins.
There is an additional informative element in that you can choose to work in the UnrealEngine.com module XYZ coordinate system or the Verse.com module LUF coordinate system.
This tutorial guides you through building the mathematical concepts that underlie the gameplay mechanics. These mechanics include:
Mapping between locations in three-dimensional world space, a two-dimensional grid game board, and a miniboard of the player's game board in the corner of your screen
Randomly placing pawns on the game board
Mathematics is used to:
Dynamically place a miniboard at runtime based on the location and rotation of a camera
Place pawns on the game board
Place markers on the miniboard
Reveal pawns within a specific distance of a tile
Randomly place pawns on the board
Build the Mechanics
To learn more about building the game mechanics of Coordinate Battle, go through the tutorial pages below:
1. Overview of Coordinate Spaces
Coordinate Battle! uses multiple coordinate spaces to define gameplay.
2. Define the Game Board
Represent game board space as tiles and manage conversion.
3. Set and Remove Pawns
Add pawns to the board and remove them when needed.
4. Generate the Board
Generate and randomly place pawns on the board.
5. Define the Miniboard
Create the miniboard and place it in the world.
6. Set Miniboard Markers
Reflect the game board state on the miniboard.
7. Construct the Game
Create the game loop logic.
8. Complete Code Files for Coordinate Battle
All of the Verse code for this tutorial in one handy place!