August
16
2016

Learn more about grid battles and how to use them.

Grid battles are available in all battle system types when using a Battle component (i.e. also when started from the auto battle settings of a combatant, e.g. spawned by a Combatant Spawner). Grid battles allow creating a very tactical battle system in your game – best suited for Turn Based or Phase battles.

When using a battle grid in a battle, the combatants will be placed on the grid and be able to move around on it. Use ranges and affect ranges of items and abilities can be defined by individual grid shapes (e.g. a line of 3 cells in front of the user) and will be highlighted on the grid (e.g. showing which cells are within use range of an ability). See this gameplay tutorial series for an example grid battle setup.

grid_battles5

You can download the Grid Prefabs to get you started. They contain some prefabs that can be used for the grid cell types – please enable Use Prefab Rotation when using these prefabs, since the prefabs already have the correct rotation set up. Additionally, a basic battle event for the move command and battle start/end events for starting/ending grid battles are included.

Download Grid Prefabs

Battle Grid Settings

The general settings for battle grids can be found at Battle System > Battle Grid Settings in the ORK Framework editor.

Grid Types

There are 2 different types of grids available – square and hexagonal grids.

Square Grids

Square grids create a chessboard like grid in the scene. A cell in the grid has 4 edges and 4 corners, i.e. 4 possible directions.

news_grid_battles1

Movement is possible horizontally and vertically, but not diagonally. A cell can have up to 4 neighbouring fields – left, right, top and bottom.

Hexagonal Grids

Hexagonal grids create a more complex grid in the scene. There are different types of hexagonal grids available – in general, every 2nd row or column in the grid will be offset. A cell in the grid has 6 edges and 6 corners, i.e. 6 directions.

A cell can have up to 6 neighouring cells, depending on the used type, movement is availalble diagonally and either horizontally or vertically.

Horizontal Even

horizontal even hexagonal grid uses hexagonal cells with a pointy top. Every even row is offset, i.e. row 0 (1st row), row 2, row 4, etc.

news_grid_battles2

Being horizontally aligned, movement is available horizontally and diagonally.

Horizontal Odd

horizontal odd hexagonal grid uses cells with a pointy top. Every odd row is offset, i.e. row 1, row 3, row 5, etc.

news_grid_battles3

Being horizontally aligned, movement is available horizontally and diagonally.

Vertical Even

vertical even hexagonal grid uses cells with a flat top. Every even column is offset, i.e. column 0 (1st column), column 2, column 4, etc.

news_grid_battles4

Being vertically aligned, movement is available vertically and diagonally.

Vertical Odd

vertical odd hexagonal grid uses cells with a flat top. Every odd column is offset, i.e. column 1, column 3, column 5, etc.

news_grid_battles5

Being vertically aligned, movement is available vertically and diagonally.

Cell Selection

The cell selection is e.g. used when the player selects a target cell for the grid move command. Cells can be selected by moving a cursor through horizontal and vertical input keys, or by using mouse/touch input.

Orientation Selection

The orientation selection is used when the player selects the orientation of a combatant (e.g. turn end orientation or grid rotation command). The orientation selection can either be started through the event system (Grid Orientation Selection step) or automatically at the end of a turn when the Turn End Orientation setting is enabled in the individual battle system’s Grid Settings (e.g. Battle System > Turn Based Battles > Grid Settings).

The orientation selection can optionally display an information dialogue while selecting (Info Text settings), as well as display confirmation dialogue when a cell was selected (Accept Question Dialogue settings). By default, the orientation selection will use the same input methods as the cell selection, but this can be overridden to use a different setup.

Combatant Placement

These settings handle how the player’s combatant placement at the start of a battle will be handled. You can trigger the combatant placement by using the Player Grid Placement step in a battle start event.

The combatant placement can optionally display an information dialogue while selecting a placement cell (Info Text settings), as well as display confirmation dialogue when a cell was selected (Accept Question Dialogue settings). By default, the combatant placement will use the same input methods as the cell selection, but this can be overridden to use a different setup.

Move Command

The move command handles a combatant’s movement on the battle grid. Beside some pathfinding settings (e.g. if combatants can move over cells blocked by their allies), you can define the default move range and battle events used to animate the move command.

The move target cell selection can optionally display an information dialogue while selecting a cell (Info Text settings), as well as display confirmation dialogue when a cell was selected (Accept Question Dialogue settings). By default, the move command will use the same input methods as the cell selection, but this can be overridden to use a different setup.

Target Cell Selection

The target cell selection is used when selecting a target for abilities and items using the None target range and having Select Target Cell enabled. Instead of selecting a combatant as a target, these actions will allow the player to select a cell – a combatant on the selected cell (or in affect range of the cell) will be used as targets.

The target cell selection can optionally display an information dialogue while selecting a cell (Info Text settings), as well as display confirmation dialogue when a cell was selected (Accept Question Dialogue settings). By default, the target cell selection will use the same input methods as the cell selection, but this can be overridden to use a different setup.

Examine Grid

The player can examine the battle grid and combatants placed on cells through the Grid Examine battle menu item. Examining a combatant can display status information (using HUD elements or already defined HUDs as templates), the move range and attack range (i.e. the use range of the base attack) of a combatant – these informations are either displayed automatically or upon using an input key.

The examine cell selection can optionally display an information dialogue while selecting a cell (Info Text settings). By default, the examine cell selection will use the same input methods as the cell selection, but this can be overridden to use a different setup.

Grid Highlighting

The grid highlighting defines how grid cells will be highlighted during different situations, e.g. when selecting a target cell for a move command.

A cell can be highlighted by spawning a prefab on the cell, and by blinking the cell (and spawned prefab).

Combatant Placement

These highlights are used during the combatant placement of the player.

  • Placement
    Highlights the cells available for placement.
  • Placement Selection
    Highlights the currently selected cell if it’s available for placement.
  • No Placement Selection
    Highlights the currently selected cell if it’s not available for placement (e.g. no placement cell or already blocked by another combatant).

Move Command

These highlights are used when selecting a target cell for a move command.

  • Move Range
    Highlights the cells available for movement.
  • Move Selection
    Highlights the currently selected cell if it’s available for movement.
  • No Move Selection
    Highlights the currently selected cell if it’s not available for placement (e.g. out of range or blocked cell).
  • Move Path
    Highlights the path to the currently selected cell (if it’s available for movement).

Target Selection

These highlights are used when selecting a target cell for an action (ability/item using None target range and Select Target Cell enabled).

  • Target Cell Selection
    Highlights the currently selected cell if it’s a valid target.
  • No Target Cell Selection
    Highlights the currently selected cell if it’s not a valid target (e.g. out of use range).

Orientation Selection

Highlights the currently selected cell when selecting the orientation.

Use Range

Highlights the use range of items and abilities. The use range can be highlighted in the action selection (e.g. when selecting an ability in the battle menu) and target selection (i.e. after accepting the ability and while selecting the target).

Affect Range

Highlights the affect range of items and abilities. The affect range can be highlighted in the action selection (e.g. when selecting an ability in the battle menu) and target selection (i.e. after accepting the ability and while selecting the target).

Examine Selection

Highlights the currently selected cell when examining the grid.

Grid Cell Types

Grid cell types are used to set up cells in the scene, they’re defined in Battle System > Grid Cell Types in the ORK Framework editor.

Cell types define the prefab that will be used to represent a cell in a grid. You can set up a position and rotation offset to the cell’s position/rotation, as well as define the prefab’s scale.

Movement Costs

The movement costs of a grid cell can be used to create different terrains. Combatants can only move for a certain move range (defined by the Move Range and move range bonuses) per turn – when a combatant moves on or over a grid cell, the move range of the combatant will be reduced by the cell’s movement costs.

E.g. moving on light terrain costs 1, while moving through a swamp or water costs 2, reducing how far a combatant can move through it. This can result in combatants being faster when moving over a bridge, even if they’d have to go a longer way for it.

Optionally, a grid cell type can be blocked, not allowing movement on it at all.

Deployment Cells

Unblocked grid cell types can be set as deployment cells for the player, allies and enemies of the player, or for all. A deployment cell is used at the start of a grid battle to determine the positions of the combatants.

E.g. the combatant placement dialogue allows the player to place group members only on deployment cells.

Cell Events

Grid cells can perform abilities or game events on combatants that move over/on a cell or start/end their turn on a cell. These cell events can be set up for grid cell types as well as in the scene setup of a grid cell.

While the start turn and end turn cell events will be performed automatically, the move over and move on cell events have to be started through the event system, e.g. by the battle event used for the grid move command. You can use the Grid Cell Event step (Add > Battle > Grid) to start cell events on grid cells.

The cell events are performed in the order they’re added to the cell or cell type – each cell event starting when the previous has finished.

Grid Scene Setup

The battle grid must be set up in the scene before it can be used in a battle. This is done using a Battle Grid component, e.g. on an empty game object.

Grid Creation

The Battle Grid component offers settings for the creation of the actual grid. You’ll be able to define the size (rows and columns) of the grid, as well as where the grid will be created (e.g. the component’s game object being the center or upper left corner of the grid).

The actual grid is created through raycasting at the cell positions – each cell is an individual game object (parented to the grid’s game object) and can be individually moved, rotated and scaled as needed.

The grid will be created using a default cell type and an empty cell type (used if the raycast didn’t hit anything). Optionally, a blocked cell type can be used, automatically setting a cell to be blocked when the ground’s slope exceeds a defined limit. It’s also optionally possible to use the slope at the cell’s position for the rotation of the cell, aligning the cells (and the cell prefabs that will be spawned on them) with the ground.

Grid Manipulation

After the grid has been created, you’re able to change it to your needs. There are 4 modes available – select, move, rotate and paint.

When the game object with the Battle Grid component or one of the grid cells is selected, the grid can optionally be displayed, each cell is represented by a blue circle in the scene view (and optionally the cell type’s prefab).

Please note that the grid will only be displayed if the grid or a cell is selected and the grid display options are enabled in the inspector. To show the grid, enable Show Grid (Editor), to also show the cell type prefabs, enable Show Prefabs (Editor).

Select

Allows selecting the individual cells. The cell type of a selected cell can be changed.

news_grid_battles6

Since the grid cells are game objects, you can use the usual ways of manipulating/changing the position, rotation or scale.

Move

Allows moving the individual cells. It’s recommended to use this mainly for changing the height of the cell (i.e. Y-axis of the position).

news_grid_battles7

Using this to swap cells or rearranging will result in unexpected behaviour in battles, since highlighting, ranges and movement will still rely on the row/column index of the cells.

Rotate

Allows rotating the individual cells.

news_grid_battles8

This can be used to further adjust a cell’s alignment with the ground.

Paint

Allows painting cell types on the grid. You can paint a selected cell type directly on the cells in the scene view by holding down the left mouse button and dragging the mouse over the cells you want to paint on.

news_grid_battles9

You can change the size of the used brush (measured in cell size).

Grid Battles

Beside setting up a battle grid in the scene (using a Battle Grid component), there are some things to consider when using grid battles.

Battle Component

The Battle Grid component only manages the battle grid, but doesn’t handle starting a battle. This is still done using a Battle component.

If a battle uses a grid (and which grid) is handled by the Grid Use Type setting in the Battle component:

  • None
    Doesn’t use a grid, i.e. regular battle.
  • Nearest Grid
    Uses the nearest Battle Grid component.
    If no grid is found, a regular battle will start.
  • Define Grid
    Allows you to select a game object with a Battle Grid component.
    If the game object doesn’t have a Battle Grid component, a regular battle will start.

When using teleport battles (e.g. like in this gameplay tutorial), set the Grid Use Type to None.

The battle grid will be set in the battle start event after changing to the battle scene (using a Load Scene step). Use a Set Battle Grid step, e.g. using the Nearest Grid if you only have one grid in the battle scene.

Use/Affect Ranges: Grid Shapes

Battle ranges can optionally define a grid shape to be used in grid battles. This is determined by the Shape Type setting.

None

No special grid treatment, the range uses the min/max range settings like in non-grid battles.

All

Uses the whole grid.

Range

Uses all cells within a defined range around the origin cell (i.e. the user). The range defines the distance on the grid, not in world space. E.g.:

  • A range of 1 uses all cells around the origin cell that can be reached with 1 step
  • A range of 2 uses the cells that can be reached with 2 steps

A range of 1 looks like this in square and hexagonal grids (visualized by using a Mask):

grid_battles__battle_range3 grid_battles__battle_range1

A range of 2 looks like this in square and hexagonal grids (visualized by using a Mask):

grid_battles__battle_range4 grid_battles__battle_range2

Mask

Uses only defind cells around the origin cell (i.e. the user). The cells are selected in a grid mask in the battle range settings.

To create a mask, define the Range and click on the Create Mask button – an empty mask will be created (based on the used grid type set up in Battle System > Battle Grid Settings). You can enable/disable cells by clicking on them.

grid_battles__battle_range5 grid_battles__battle_range6

Abilites and Items: None Target Range

When using the None target range for an ability or item, you can enable the Select Target Cell option to allow the player to select a grid cell as target for the action.

The target cell selection is set up in Battle System > Battle Grid Settings. You can also display the affect range of the ability when selecting a target cell – upon accepting a selected cell, all combatants in the affect range will be used as targets.

Battle AI

There are several new battle AI steps available to handle AI controlled combatants (e.g. enemies) in grid battles.

Grid Move

This step will use the Grid Move command – either moving toward a target, flee from a target or moving to a random cell in move range. When using a target, a previously found target (i.e. determined by the battle AI) will be used.

The battle AI ends if the user can perform a grid move command. If no grid move command can be executed (e.g. due to no move range left or reachable cells are currently blocked by other combatants) the Reachable slot will be executed next – a target is reachable if one of it’s neighbouring cells is a valid move target (i.e. not blocked or occupied by another combatant). Otherwise the Next slot will be executed.

Check Grid Distance

This step will check the grid distance (i.e. the cell distance) between the user and targets. Neighbouring cells have a grid distance of 1.

Targets that have a valid check (e.g. being farther away than 1 cell) will be added to the found targets list.

Grid Rotate To Target

This stepp will change the user’s grid orientation to look at a previously found target (i.e. determined by the battle AI). The battle AI will continue after this step.

Since use ranges in grid battles can depend on which way the combatant is looking (i.e. grid shapes), this can be useful to turn AI combatants toward their targets before trying to use actions.

Event System

There are several new event steps available for grid battles, they’re available in Battle > Grid steps.

Depending on which event type you’re using, there are different steps available.

Battle Start Events

The most important battle grid steps for battle start events are:

  • Show Battle Grid
    Use this step to show the battle’s grid if it isn’t set to automatically show on scene load.
  • Player Grid Placement
    Starts the Combatant Placement to allow the player to place group members on deployment cells.
  • Place On Grid
    Makes sure to place all combatants that participate in the battle are placed on grid cells.
    If a combatant isn’t yet placed on the grid, it’ll be placed on the nearest free cell – the optional Use Deployment Cells setting will place combatants at the nearest free deployment cell.
  • Set Battle Grid
    When using teleport battles, use this step after the battle scene was loaded to set the battle’s grid in the new scene.

Battle End Events

The most important battle grid steps for battle end events are:

  • Show Battle Grid
    Use this step to hide the battle’s grid if it shouldn’t be displayed after the battle.

Battle Event for Grid Move Command

If you want to animate how a combatant follows the path to the target grid cell, you’ll need to do this in the battle event used to animate the grid move command. The downloadable grid prefabs contain an example of how this can be done.

In short, you’ll need at least 3 steps that cycle through the path cells:

grid_battles__move_command1

  • Check Grid Path Length
    Check if there’s still a cell left on the path (i.e. greater 0).
  • Store Grid Path
    Store the current path cell as a found object and remove it form the path.
  • Change Position (or other movement nodes)
    Move to the position of the path cell that was stored as a found object.

This cycle will go through all path cells and move the user along the path until the target cell is reached.

In case you’re using Move Over Allies or Move Over Enemies in the pathfinding settings of the move command, you’ll also have to deal with combatants that stand on those cells, e.g. move them to the side or disable their colliders to move through them. The combatant of a cell can be used through the selected data feature, i.e. use a Select Combatant step to select the combatant from the stored grid cell.

The example battle event provided in the grid prefabs will disable the colliders (and NavMeshAgents) of all combatants on the path at the beginning of the event and enable them at the end.

In case you’re using Cell Events with the Move Over and Move To start types, you’ll need to start them in the grid move command’s battle event. This is done using Grid Cell Event steps when moving along the path. It’ll change the cycle to look like this:

grid_battles__move_command2

The example in the grid prefabs shows how this can be done.

Battle Events

In general, you’ll want to avoid using battle events like runToTarget and runToBase from the game tutorial series when fighting grid battles, as they don’t fit how grid battles are fought.

Also, don’t use Reset Look Angles option in the Event Settings of battle events or Look At Enemies steps. While they’ll automatically adjust to grid orientations when used in grid battles, they’ll interfere with selected grid directions and look at the center of the enemy group, instead of at their direct target.