Unity Tutorial – Tactics Movement

Tactics games, like Final Fantasy Tactics and Ogre Tactics, are turn-based combat games on square tiles. This multi-video tutorial will cover movement for a tactics game.

Player movement uses Breadth First Search (BFS) to calculate the tiles that the player’s unit can move to. NPC movement uses A* to calculate a path to the nearest player unit, and then limits the path to the unit’s maximum movement.

Part 1 – covers how to set up the tactics game board
Part 2 – covers how to set up the adjacency list for each tile
Part 3 – covers Breadth First Search (BFS) for calculating the tiles the player can move to
Part 4 – covers movement of the unit’s from tile to tile, including jumping up and down
Part 5 – covers the turn manager so the player and NPC can take turns moving
Part 6 – covers A* and NPC movement which chases after the player

Download this Unity tutorial

Videos

Part 1 – covers how to set up the tactics game board

Part 2 – covers how to set up the adjacency list for each tile

Part 3 – covers Breadth First Search (BFS) for calculating the tiles the player can move to

Part 4 – covers movement of the unit’s from tile to tile, including jumping up and down

Part 5 – covers the turn manager so the player and NPC can take turns moving

Part 6 – covers A* and NPC movement which chases after the player

Posted in AI, Artificial Inteligence, Code, Game Programming, Tutorials, Unity 3D.

9 Comments

  1. I have a problem with part 3 : my code is identical to yours, but my tiles dont become red : they’re not “selectable”, but the “current” tile (the pink one) is displayed both current AND selectable. I dont find where i made a mistake

    • Same exact problem. Using Unity 2018.4. The YT comments on that video suggested making sure the “if (!Physics.Raycast(tile.transform.position, Vector3.up, out hit, 1))” is correct, and it is for me. The other thing to look for is making sure each tile gameObject has the Tile script and tagged as Tile, which they are. The Main Camera is tagged as Main Camera, and the Player is tagged as Player.

  2. I’m trying to make it so if player doesnt use full moves he can move again with left over moves. I have it working so the player moves say 3 spaces and then the selectable tiles shrink to 2 spaces properly, but when I move the last 2 spaces and ends turn the NPC goes into a turn loop. I cant figure out how to make NPC stop at its 5 spaces to end turn

  3. So if we follow along with these videos and make a game based off of what we did, are we allowed to sell it? even if some of the scripts are unchanged?

  4. I followed the entire tutorial and I keep getting an error…

    “NullReferenceException: Object reference not set to an instance of an object
    TacticsMovement.GetCurrentTile () (at Assets/Scripts/TacticsMovement.cs:45)
    TacticsMovement.FindPath (TileScript target) (at Assets/Scripts/TacticsMovement.cs:330)
    NPCMove.CalculatePath () (at Assets/Scripts/NPCMove.cs:41)
    NPCMove.Update () (at Assets/Scripts/NPCMove.cs:28)”

    I have everything tagged and named correctly, but I continue to get this error. Please help, thank you!

Leave a Reply

Your email address will not be published. Required fields are marked *