In this tutorial we’ll set up the grid move command.
This tutorial is part 4 of a mini-series covering grid battles. You can find the start of this series here.
The grid move command is used by combatants to perform movement on the grid. For the player this involves a move target cell selection – using the highlights we set up earlier the player will see the move range and path during the selection. The actual movement is handled by a schematic, like any action used in battle.
We’ll set up:
- grid move schematic
- move range formula
- move command
- update phase battle action cost
- add grid move command to battle menu
- add battle AI using grid move command (and add to combatants)
This tutorial is based on the ORK 4 Unity Quickstart 3D tutorials and using a phase battle system, but can be used in any project and with any battle system.
Grid Move Schematic #
We’ll start with the schematic.
We’ll create a simple schematic to animate the grid move action. We’ll follow the selected path cell by cell, performing possible grid cell events on the cells we move over/to.
Movement is handled using the Change Position node – the setup described here will use the Auto move component selection. This’ll try to select the appropriate component for movement, but this might not result in the desired outcome for all setups. If movement doesn’t work in your setup, try one of the different move components based on your setup (e.g. Character Controller or Combatant Movement Component).
The user of the action is the Machine Object of the schematic, the path from the user’s current position to the target position can be accessed via nodes.
Check Grid Path Length #
Add Node > Battle > Grid Path > Check Grid Path Length
We’ll first check if there even is a grid path, i.e. if it’s length is greater than 0.
- Check Type
Select: Is Greater - Check Value
Select: Value > Value
Set the value to: 0
Store Grid Path #
Add Node > Battle > Grid Path > Store Grid Path
This node is used to store a cell from the path into selected data – you can either store the whole path, the next or last cell.
We’ll store the next cell on the path and also remove the cell from the path, so that we can later continue with the next cell after this one.
This node is connected to the Success slot of the previous node.
- Data Key
Set to: cell - Data Origin
Select: Local - Change Type
Select: Set - Cell Selection
Select: Next - Remove Cell
Enable
Change Position #
Add Node > Movement > Movement > Change Position
We’ll now move the user (Machine Object) to the stored cell.
- Object (Moving Object)
Select: Machine Object - Move Component
Select: Transform
Please note that you might need to use a different selection based on your setup. - To Object
Enable - Object (Target Position)
Select: Selected Data - Data Key
Set to: cell - Data Origin
Select: Local
We’ll move to the cell instead of setting directly to the position.
- Move
Enable - Wait
Enable
We wait for the movement to finish before continuing. - Apply Gravity
Enable - Face Direction
Enable - Rotate Component
Select: Transform
Just like the Move Component, this might need a different component based on your setup. - Move By Speed
Disable
We’ll interpolate to the new position. - Time
Select: Value > Value
Set the value to: 0.25 - Interpolation
Select: Linear
You can also enable Move By Speed and move at a fixed speed instead.
Set Grid Cell Combatant #
Add Node > Battle > Grid Cell > Set Grid Cell Combatant
We’ll register the combatant on the cell we just moved to.
- Object (Combatant Settings)
Select: Machine Object - Set As
Select: Move
This’ll register the combatant as moving on the cell.
In case another combatant is already on the cell it’ll not replace it. - Object (Grid Cell Settings)
Select: Selected Data - Data Key
Set to: cell - Data Origin
Select: Local
Check Grid Path Length #
Copy the first Check Grid Path Lengt node.
We’re done with our move to the next cell, so we’ll check if we finished the path.
Grid Cell Event #
Add Node > Battle > Grid Cell Event > Grid Cell Event
We don’t use grid cell events in our tutorial, but it’s always good to have them included in your grid move in case you later add them.
Grid cell events perform certain things when a combatant moves over or moves to a cell, or starts/ends their turn on a cell. E.g. you can change status effects, use schematics or an ability on the combatant.
This node is connected to the Success slot of the previous Check Grid Path Length node, i.e. we still have some of the path left to go.
The Next slot of this node is connected back to the Store Grid Path node.
- Start Type
Select: Move Over
We’re continuing on the path, i.e. we move over this cell. - Wait
Enable
The rest of the setup should already be correct:
- Object (Cell Object)
Select: Selected Data - Data Key
Set to: cell - Data Origin
Select: Local - Object (Combatant)
Select: Machine Object
Grid Cell Event #
Copy the previous Grid Cell Event.
This node is connected to the Failed slot of the previous Check Grid Path Length node, i.e. we’re done with our move.
- Start Type
Select: Move To
We’re done with the path, i.e. we move to this cell.
Wait (Optional) #
Add Node > Base > Wait
We’ll wait for a short time, just to slow things down a bit.
- Time
Select: Value > Value
Set the value to: 0.5
And that’s it for the schematic. Click on Save Schematic to save it as GridMove.
Move Range Formula #
Grid movement is based on a move range available to a combatant.
We’ll use a formula to calculate the move range based on the AGI status value. The formula will divide AGI by 5 (i.e. 1 point every 5 AGI) and add a base move range of 3.
Open the ORK editor, navigate to Gameplay > Formulas and add a new formula.
Formula Settings #
We’ll limit the move range t0 20 (cells), we handle this via the maximum value of the formula.
- Name
Set to: Move Range - Use Maximum Value
Enable - Maximum Value
Select: Value > Value
Set the value to: 20
Status Value #
Add Node > Combatant > Status Value
We add the agility of the user.
- StatusValue
Select: AGI
Value #
Add Node > Value > Value
We now divide by 5.
- Operator
Select: Divide - Value
Select: Value > Value
Set the value to: 5
Value #
Add Node > Value > Value
Add 3 for our base move range.
- Operator
Select: Add - Value
Select: Value > Value
Set the value to: 3
Math Function #
Add Node > Base > Math Function
This node is used to use a defined math function on the formula’s result.
We’ll use it to round the current value, e.g. 5.4 will become 5, 5.6 will become 6.
- Math Function
Select: Round
That’s it for the formula
Move Command Setup #
With all our needed parts set up, we can now set up the move command.
Navigate to Battles > Battle Grid Settings and change the Move Command settings.
Move Command #
- Use Only Once
Enable - Player (Use Only Once)
Disable
Player combatants can use grid movement as long as they have move range left.
Keep the others enabled, i.e. enemies can only move once. - Allow Cancel
Enable - Use Shortest Path
Enable - Move Over Allies/Enemies
Disable
We can’t move over cells that are already occupied by another combatant.
Enable these settings in case you want to allow moving over other combatants. - Default Move Range
Select: Value > Formula
Select formula: Move Range - Camera Control Target
Enable
The camera will target the selected cell during the grid move cell selection.
Default Battle Animation #
This is where we set up our grid move schematic – combatants can optionally override the default animation.
Click on Add Battle Animation.
- Schematic Asset
Select: GridMove
Update Phase Battle Action Cost #
If you’re using the phase battle system setup, we’ll also adjust the action cost for grid movement. Instead of the default 2 AP, it should only cost 1 AP.
Navigate to Battles > Battle System and select the Phase battle system.
Action Settings #
- Own Grid Move Cost
Enable - Action Cost
Select: Value > Value
Set the value to: 1
Battle Menu #
Next we’ll add the grid move command to the battle menu.
Navigate to Menus > Battle Menus and select the Default battle menu.
Copy Option 0 (the Attack command) and change the newly added copy (Option 1).
- Type
Select: Grid Move - Use Action Info
Enable
This’ll use the content information of the grid move command and also display the action costs.
Battle AI #
We’ll add a new battle AI that handles grid movement for the enemies. The battle AI will move to the nearest alive enemy of the user.
Navigate to Battles > Battle AIs and add a new battle AI.
Battle AI Settings #
- Name
Set to: Grid Move
Check Status #
Add Node > Combatant > Check Status
We’ll find an alive enemy before selecting the nearest of them.
- Found Targets
Select: Clear - Target
Select: Enemy
Click on Add Status Condition.
- Status Needed
Select: Death - Is Dead
Disable
Get Nearest #
Add Node > Position > Get Nearest
We’ll now selected the nearest found target (i.e. the nearest alive enemy).
This node is connected to the Success slot of the previous Check Status node.
- Found Targets
Select: Check - Target
Select: None - Use Grid Distance
Enable
Grid Move #
Add Node > Action > Grid Move
This node selects a path to a target (cell) and uses the grid move action. We’ll move to the found target (i.e. the nearest enemy).
- Move Type
Select: Move Toward Target - Target Cell
Select: Nearest
Target Cell Settings #
These settings define which cells around the target are valid to move to – we’ll use the default setup, i.e. a distance of 1.
- Range Type
Select: Distance - Minimum Distance
Set to: 1 - Maximum Distance
Set to: 1
Updating Combatants #
We’ll add the grid move battle AI to our combatants.
Navigate to Combatants > Combatants.
We’ll add the new battle AI to the General Settings and the following combatants:
- Spider
- Skeleton
- Slime
These combatants replace the default battle AI instead of adding to it, so we need to add the new battle AI to them individually.
The setup is the same for all, so repeat it for the general settings and 3 combatants.
AI Settings > Battle AI #
We’ll set the grid move battle AI as the first battle AI in the list, i.e. it’ll be used before all other.
Copy Battle AI 0 and change the settings of the original.
- Battle AI
Select: Grid Move
Save Changes #
And that’s it for the grid move command setup.
Don’t forget to save your changes by clicking on Save Settings at the bottom of the editor.
The next part of the grid mini-series will finally set up battle grids in our battle arena scenes.




