07 Battle Grid Setup

In this tutorial we’ll set up the battle grid settings.

You can learn more about battle grids in this documentation.

We’ll set up:

  • battle grid settings (excluding the grid move command, which we’ll set up in the next tutorial)
  • battle grid highlights
  • grid cell types

Let’s get to it.

Battle Grid Settings #

We start with setting up the overall battle grid settings.

Navigate to Battles > Battle Grid Settings.

Grid Settings #

We’ll use Square grids.

  • Grid Type
    Select Square.
  • Cell Size
    Set to 1.
    A cell has a size of 1 world unit, which matches the size of our tiles.
  • Cell Offset
    Set to X=0, Y=0.
    We don’t add an offset between cells, they already fit perfectly into our tiles.

The Raycast Settings are used to find cells based on the cursor position. Our ground is on the Default layer, so we’ll use that.

  • Layer Mask
    Select only the Default layer.
    First select Nothing, then select Default.

Cell Selection #

These settings handle how cells can be selected, e.g. for placing combatants, selecting the cell to move to or for cell-based target selections.

Individual grid operations can replace this default setup with a custom cell selection, if needed.

Input Key Settings #

We’ll use input keys to select cells, i.e. we can navigate the grid with vertical/horizontal input.

  • Use Input Keys
    Enable this setting.
  • Vertical Axis
    Select Vertical Menu.
  • Horizontal Axis
    Select Horizontal Menu.

Mouse/Touch Control #

We’ll also allow selecting cells using the mouse cursor.

  • Input Type
    Select Mouse.

The default setup uses the left mouse button with a single click, which is already correct for us.

  • Hover Select
    Enable this setting.
  • UI Blocks Cursor Over
    Enable this setting.
    E.g. having the cursor over the battle menu prevents selecting cells via hover select.
  • Cursor Move Only
    Enable this setting.
    Hover select is only used when the mouse is moved.

Audio Settings #

Cell selections should make some noise, just like menu selections.

  • Select Audio
    Select Menu2.
  • Accept Audio
    Select Menu5.
  • Cancel Audio
    Select Menu4.
  • Fail Audio
    Select Menu6.

Orientation Selection #

These settings are used for selecting the grid orientation of a combatant.

We’re not using this feature.

Combatant Placement #

These settings handle the player’s grid placement we’re using in the battle start schematic (via the Player Grid Placement node).

  • Select Battle Group
    Enable this setting.
    The grid placement will select the combatants that are part of the battle group.
  • Use Whole Group
    Enable this setting.
    All members of the player group (excluding the hidden player) will be available.
  • Use Selection
    Enable this setting.
    We’ll use the combatant selection we’ve set up.
  • Combatant Selection
    Select Grid Placement.
  • Place On Selection
    Enable this setting.
    The prefab of the combatant we’re placing will be spawned while placing, i.e. it’ll show up on the cell we select.
  • Allow Cancel
    Enable this setting.
  • Camera Control Target
    Enable this setting.
    The camera control will target the selected cell.

Move Command #

These settings handle the grid movement – we’ll set this up in the next tutorial.

Target Cell Selection #

These settings are used for abilities and items that target cells instead of combatants.

We’ll use this for some of the magic abilities – cell selection targeting can be used when an ability uses the None target range.

  • Allow Cancel
    Enable this setting.
  • Camera Control Target
    Enable this setting.
    The camera control will target the selected cell.

Examine Grid #

These settings handle the examine command and can optionally be used to always examine a selected cell (e.g. during move or target selections).

Examind cells can display various information about the cell and combatants on the cell.

We’ll not use this for our short tutorials.

That’s it for the overall battle grid setup.

Battle Grid Highlights #

Next, we’ll manage grid highlights – they’re used to, as the name suggests, highlight grid cells. We’ll use this to e.g. show the move range of a combatant, the use range of actions or the selected cell. You can learn more about grid highlights in this documentation.

Navigate to Battles > Battle Grid Highlights.

Base Highlight Settings #

We can set up some default highlights for other highlights to use. Each individual highlight can also use a custom highlight.

There are generally 3 different highlights:

  • area highlights for showing an area (e.g. a move range)
  • selection highlight for showing the selected cell
  • no selection highlight for showing the selected cell if it’s not available (e.g. outside the move range)

There are also 3 different ways to highlight cells, you can also use them together:

  • spawning a prefab on the cell
  • blinking the cell’s color
  • using a line renderer

We’ll use prefabs (for single cells) and blinking (for areas). The cell prefabs we’ll use when setting up the grid cell types (following the highlights) are made up of 2 sprites, one completely white sprite but with no alpha (i.e. fully transparent) at it’s base and another sprite above it. When blinking, we’ll only blink the white sprite in a color.

  • Hide Unused Prefabs
    Enable this setting.
    This’ll be enabled by default in a new project.
    In short, this’ll only hide prefabs of unused highlights by disabling their renderers, making them invisible.
    Otherwise it’ll disable the prefab’s game object – hiding it can be better for performance, though this can vary based on the use case.

Area Highlight #

We’ll blink areas blue as the default highlight.

  • Use Blink
    Enable this setting.
  • Blink Children
    Disable this setting.
    We only want to blink the sprite at the root.
  • Fade Alpha/Red/Green/Blue
    Enable these settings.
  • Start Color
    Select a blue color with around a third of alpha value (e.g. A=100 or 0.4, depending on your color picker).
  • Start Color
    Select a blue color with around half of alpha value (e.g. A=150 or 0.6, depending on your color picker).

Selection Highlight #

We’ll use a prefab for selections.

  • Use Prefab
    Enable this setting.
  • Prefab
    Select GridCursor.
    You can find the prefab in Assets/Tutorial Assets/Prefabs/GridCells/.

No Selection Highlight #

We’ll use a prefab for selections.

  • Use Prefab
    Enable this setting.
  • Prefab
    Select GridCursorRed.

Combatant Cell #

We’ll highlight the cells of enemies to make the distiguishable from the player combatants – since they all use the same 6 combatants (even when randomized).

  • Use Combatant Cells
    Enable this setting.

Enemy Cell #

  • Use Highlight
    Enable this setting.
  • Own Highlight Settings
    Enable this setting.
    We’ll use a red cursor prefab.
  • Use Prefab
    Enable this setting.
  • Prefab
    Select GridCursorRed.

Combatant Placement #

We’ll use the default highlights for the player’s combatant placement.

Placement #

  • Use Highlight
    Enable this setting.
  • Base Highlight
    Select Area.

Placement Selection #

  • Use Highlight
    Enable this setting.
  • Base Highlight
    Select Selection.

No Placement Selection #

  • Use Highlight
    Enable this setting.
  • Base Highlight
    Select No Selection.

Move Command #

While we’ll set up the move command in the next tutorial, we can already set up the highlight for it.

Move Area #

  • Use Highlight
    Enable this setting.
  • Base Highlight
    Select Area.

Move Selection #

  • Use Highlight
    Enable this setting.
  • Base Highlight
    Select Selection.

No Move Selection #

  • Use Highlight
    Enable this setting.
  • Base Highlight
    Select No Selection.

Move Path #

We’ll highlight the path with blinking cells in a cyan color.

  • Use Highlight
    Enable this setting.
  • Own Highlight Settings
    Enable this setting.
  • Use Blink
    Enable this setting.
  • Blink Children
    Disable this setting.
  • Fade Alpha/Red/Green/Blue
    Enable these settings.
  • Start Color
    Select a cyan/light blue color with around a third of alpha value (e.g. A=100 or 0.4, depending on your color picker).
  • Start Color
    Select a cyan/light blue color with around half of alpha value (e.g. A=150 or 0.6, depending on your color picker).

Selected Target #

We’ll highlight the selected target (during the target selection, using a green prefab for players and a red prefab for enemies.

Selected Target (Player) #

  • Use Highlight
    Enable this setting.
  • Own Highlight Settings
    Enable this setting.
  • Use Prefab
    Enable this setting.
  • Prefab
    Select GridCursorGreen.

Selected Target (Enemy) #

  • Use Highlight
    Enable this setting.
  • Own Highlight Settings
    Enable this setting.
  • Use Prefab
    Enable this setting.
  • Prefab
    Select GridCursorRed.

Target Cell #

We’ll highlight the cell during cell target selections using the default highlights.

Targe Cell Selection #

  • Use Highlight
    Enable this setting.
  • Base Highlight
    Select Selection.

No Target Cell Selection #

  • Use Highlight
    Enable this setting.
  • Base Highlight
    Select No Selection.

Use Range #

We’ll highlight the use range of actions with blinking cells in red color.

  • In Action Selection
    Enable this setting.
    The cells will be highlighted when the action is selected, e.g. in the battle menu.
  • In Target Selection
    Enable this setting.
    The cells will be highlighted while selecting the target for the action.
  • Use Highlight
    Enable this setting.
  • Own Highlight Settings
    Enable this setting.
  • Use Blink
    Enable this setting.
  • Blink Children
    Disable this setting.
  • Fade Alpha/Red/Green/Blue
    Enable these settings.
  • Start Color
    Select a red color with around a third of alpha value (e.g. A=100 or 0.4, depending on your color picker).
  • Start Color
    Select a red color with around half of alpha value (e.g. A=150 or 0.6, depending on your color picker).

Affect Range #

We’ll highlight the affect range of actions with blinking cells in yellow color.

We’ll use affect ranges for some of our magic abilities to not only target a combatant or cell, but also surrounding cells.

  • In Target Selection
    Enable this setting.
  • Use Highlight
    Enable this setting.
  • Own Highlight Settings
    Enable this setting.
  • Use Blink
    Enable this setting.
  • Blink Children
    Disable this setting.
  • Fade Alpha/Red/Green/Blue
    Enable these settings.
  • Start Color
    Select a yellow color with around a third of alpha value (e.g. A=100 or 0.4, depending on your color picker).
  • Start Color
    Select a yellow color with around half of alpha value (e.g. A=150 or 0.6, depending on your color picker).

Selecting Combatant #

We’ll highlight the combatant who’s currently selecting actions with a green prefab. We’ll only highlight the player combatants, since the enemies all alrea already highlighted by a red cursor.

Selecting Player #

  • Use Highlight
    Enable this setting.
  • Own Highlight Settings
    Enable this setting.
  • Use Prefab
    Enable this setting.
  • Prefab
    Select GridCursorGreen.

That’s it for the grid highlights we’ll use.

Battle Grid Cell Types #

We’ll continue our setup with the grid cell types – they’ll be used by our battle grids in the scene to show their cells and define the cost for moving on them.

Navigate to Battles > Battle Grid Cell Types, we’ll change the Default cell type and add additional cell types.

0: Ground #

We’ll start with a standard ground cell. It’ll have a move cost of 1.

  • Name
    Set to Ground.

Prefab Settings #

  • Prefab
    Select GridCell.

Cell Settings > Costs #

  • Move Costs
    Select Value > Value.
    Set the value to 1.

1: Ground Slow #

Copy the Ground cell type, this’ll be used as a harder to move over ground and have a move cost of 1.5.

  • Name
    Set to Ground Slow.

Cell Settings > Costs #

  • Move Costs
    Select Value > Value.
    Set the value to 1.5.

2: Blocked #

Add a new cell type – this cell will not have a prefab (i.e. it’s an empty cell) and will be blocked, i.e. no movement on this cell.

  • Name
    Set to Blocked.

Cell Settings #

  • Blocked
    Enable this setting.

3: Player Spawn #

Copy the Ground cell type, this’ll be a regular ground cell that allows player combatants to spawn on them.

  • Name
    Set to Player Spawn.

Cell Settings > Deployment Settings #

  • Deployment Type
    Select Player.

3: Enemy Spawn #

Copy the Player Spawn cell type, this’ll be a regular ground cell that allows enemy combatants to spawn on them.

  • Name
    Set to Enemy Spawn.

Cell Settings > Deployment Settings #

  • Deployment Type
    Select Enemy.

Save Changes #

And that’s it for the battle grid setup.

Don’t forget to save your changes by clicking on Save Settings at the bottom of the editor.

 

Next, we’ll set up the move command.