Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

[RELEASED] Turn Based Strategy Framework

Discussion in 'Assets and Asset Store' started by michal-zetkowski, Jul 2, 2019.

  1. michal-zetkowski

    michal-zetkowski

    Joined:
    Mar 11, 2015
    Posts:
    282
    This project is a highly customizable framework for turn based strategies. It allows to create custom shaped cell grids, place objects like units or obstacles on it and play a game with both human and AI players. The framework was designed to allow implementing various gameplay mechanisms easily. Please, check out document linked below for more information.


    Main features of TBS Framework:
    • Covers all aspects of turn based game, including map generation, pathfinding, combat and game progression
    • Contains Grid Helper custom inspector for setting up a scene automatically
    • Tile and Unit Painter introduced in v2.0 make designing maps easier than ever
    • Comprehensive project documentation
    • Responsive support over email or forum thread
    • Helped many devs finish their hobby project, school assignment or release a game to market

     
    Last edited: Apr 7, 2022
  2. michal-zetkowski

    michal-zetkowski

    Joined:
    Mar 11, 2015
    Posts:
    282
    Hey everyone. Because user base of the project grew quite large, I decided it would be good to set up a forum thread. I will check up on the thread as often as I can, I look forward to chating with you :). You can also reach me directly at crookedhead@outlook.com
     
    stoven91 and MyReazon like this.
  3. ringlas

    ringlas

    Joined:
    May 16, 2017
    Posts:
    1
    It's an awesome asset I cannot recommend enough! After implementing it in Dust and Salt 2 years ago, I'll be using it for my next, bigger project as well.
     
    MyReazon and f4bo like this.
  4. michal-zetkowski

    michal-zetkowski

    Joined:
    Mar 11, 2015
    Posts:
    282
    Thanks! Please keep us updated about your project :).
     
    MyReazon likes this.
  5. chocx

    chocx

    Joined:
    Jul 30, 2019
    Posts:
    1
    Hello, does this framework can be used or modify easily for an 2D isometric tile system? Thanks ;)
     
  6. michal-zetkowski

    michal-zetkowski

    Joined:
    Mar 11, 2015
    Posts:
    282
    Hey, thanks for you message :). It can be used with isometric tiles. Let me know here or by email if you have any issues.
     
  7. NoradZero

    NoradZero

    Joined:
    Apr 24, 2014
    Posts:
    95
    Quick question, it is possible to add height to 3D levels? By that i mean, can we move an unit from floor to an higher area with stairs?
     
  8. michal-zetkowski

    michal-zetkowski

    Joined:
    Mar 11, 2015
    Posts:
    282
    Hey, it's not available out of the box, but you can easily add it. The steps are as follows: add a public 'height' field to Cell, you will have to set it in editor later. Next, modify GetNeighbours method in Cell class to take height into account (like cells that have height difference greater than 1 should not be neighbours). That's it. Let me know if you need more detailed explanation.
     
    mebaucco and MyReazon like this.
  9. mix5rock

    mix5rock

    Joined:
    Oct 21, 2019
    Posts:
    3
    Hi! I was wondering of how create an rpg class system going for the units. I would preferably want to grab unit data from a database instead of inputting individual values for each unit that way it would be quicker the data autofills the values for me.
     
  10. michal-zetkowski

    michal-zetkowski

    Joined:
    Mar 11, 2015
    Posts:
    282
    Hey, I don't see any issues with your approach. You can set up units on the grid without setting their properties manually, and fill them with values from the database when level is loading. Do you have any more specific questions about this?
     
  11. mix5rock

    mix5rock

    Joined:
    Oct 21, 2019
    Posts:
    3
    having a little trouble figuring out how to get it to appear in the UI.
    upload_2019-10-23_18-19-3.png
    upload_2019-10-23_18-18-25.png

    although this method is having a script for each class. if i could make a database of classes and do the same thing would be helpful:
    upload_2019-10-23_18-20-14.png

    P.S. I'm not really used to C# yet. i have experience w Python but learning C# on the fly is giving me some trouble. Any help is appreciated, thanks!
     
  12. michal-zetkowski

    michal-zetkowski

    Joined:
    Mar 11, 2015
    Posts:
    282
    Hey, I assume that you are basing your level on my example scenes, right? The code on the first two screenshots seems fine - Equipped weapon field should appear in Unity editor when you select Archer unit. On the second screenshots you are updating StatsText variable - assuming that you have this field assigned in the editor, it should work fine.

    Regarding the last screenshot - I don't really get this inheritance relation between Classes and MyUnit.

    Would you mind continuing the conversation over email? (crookedhead@outlook.com)? I would like to use this thread for issues that I can solve in 1 - 2 posts so it is easier to follow for the new readers.
     
  13. mix5rock

    mix5rock

    Joined:
    Oct 21, 2019
    Posts:
    3
    Yes I am using your examples as references. I got the equipped weapon to appear so thanks for the hint. I will follow up on email.
     
    DScaddan likes this.
  14. Beleth1379

    Beleth1379

    Joined:
    Jan 18, 2019
    Posts:
    2
    Hello, I would like to know if this framework can be used or easily modify to have turn based battles but, on the same grid , having real time movement .

    To be more clear, character move around freely in real time around the map with the grid but when there are enemies it begins a turn based combat with the grid, like Spiderweb games for exemple ( avernum, geneforge etc).
    Sorry if it's a dumb question but I'm still learning.
     
  15. michal-zetkowski

    michal-zetkowski

    Joined:
    Mar 11, 2015
    Posts:
    282
    Hey, I looked at the games that you mentioned and have an idea about what you want to achieve. Is it possible to use the framework for a game like that? Without modifications - definitely not. Will the modificatoin be easy? Well, the framework was designed for turn based combat. I heard from users that tried to use it for some real-time action, but didn't see what they come up with. Perhaps you could go for a hybrid solution, that would use the framework for combat and a different mechanics for real-time parts? Anyway, I'll be happy to help.
     
  16. Beleth1379

    Beleth1379

    Joined:
    Jan 18, 2019
    Posts:
    2
    Hey, thank you for the swift reply! I thought about the hybrid solution because it's really easy but also common and "older" that's why i was wondering how to fuse together.

    I think I'll try the hybrid for the moment , better to stay classic while I'm learning. Anyway you did a fantastic job! And thank you for your support!
     
  17. Shar_ds

    Shar_ds

    Joined:
    Sep 16, 2013
    Posts:
    2
    Hi,

    On this same theme, is there any easy way to add a multiplier to tile cost for transitioning to a greater height? e.g. climbing up a step should cost 1.2 times as many MP? I'm thinking similar for 1.5 times movement cost for diagonal movement on a square grid (after adapting GetNeighbours to recognise diagonals as neighbours).

    Or is this a matter of editing the pathfinding algorithm to factor in this transition cost?

    Ta!
     
  18. michal-zetkowski

    michal-zetkowski

    Joined:
    Mar 11, 2015
    Posts:
    282
    Hey,

    The problem here is that MovementCost is just a field on the cell object, it does not take into account what cell the unit is moving from. To fix that you could add a method like getMovementCost(Cell otherCell) to Cell class. The method would take the other cell as parameter and based on its height would return either regular or multiplied MovementCost. Next, you would need to replace MovementCost references in pathfinding scripts with getMovementCost method. This should not be a big deal.

    Regarding diagonal movement - you've got the right idea, you need to change GetNeighbours and GetDistance methods in Square class.
     
    mebaucco likes this.
  19. Shar_ds

    Shar_ds

    Joined:
    Sep 16, 2013
    Posts:
    2
    Thanks!

    So I don't think that Dykstra uses the Distance between cells at all, and AStar I think currently only uses it to prioritise the pathway selection? I don't think that any of the pathfinding algorithms use GetDistance to affect the cost of moving on a certain path yet? Is that right? If so, that's fine, I can figure out a solution.

    Also, can you tell me where the MovementCost gets taken into account? I can't find a reference to the variable anywhere in the solution. The costs obviously work, but I can't figure out why or how, so can't modify them on the fly!
     
  20. michal-zetkowski

    michal-zetkowski

    Joined:
    Mar 11, 2015
    Posts:
    282
    Hey,

    You are right about GetDistance regarding pathfinding. It is used in a couple of different places though, like determining unit attack range.

    MovementCost is used in GetGraphEdges in Unit class. You should replace the line

    Code (CSharp):
    1. ret[cell][neighbour] = neighbour.MovementCost;
    with something like this

    Code (CSharp):
    1. ret[cell][neighbour] = cell.GetMovementCost(neighbour);
     
  21. SecretAnorak

    SecretAnorak

    Joined:
    Mar 19, 2014
    Posts:
    177
    Love the framework, having tons of fun with it, but I've come across a bizarre issue which I can't work out.

    When generating 2d hex maps the grid generator suddenly starts flipping my tiles 90 degrees and generating the map in the XZ Plane. Any idea why this might be happening?
    I am using flat-ish 64x32 hexes but I've had the maps generate fine once or twice then suddenly they change axis?

    EDIT: Ah ok, I think i get it now (after reading the note at the start of the manual). I need to let the map generate in XZ then roll the CellGrid in x-90. Weird, but it seems to work.

    EDIT2: Nope it's still driving me crazy. I thought I'd try square sprites but no matter what I do, the grid generates in the XZ plane, but my sprites are rotated to XY, giving this:

     
    Last edited: Dec 10, 2019
  22. michal-zetkowski

    michal-zetkowski

    Joined:
    Mar 11, 2015
    Posts:
    282
    Hey,

    I get this issue myself from time to time. My guess is that your problem is either cell prefab rotated in wrong direction, wrong GetCellDimensions implementation or both. To clear things up: in Framework v1.1.2 cell prefab needs to be rotated like in the picture below. GetCellDimensions method should return Vector3 with width as x component and height as z component. Let me know if that helped.

    upload_2019-12-11_16-59-42.png
     
  23. Diputs

    Diputs

    Joined:
    Feb 14, 2014
    Posts:
    9
    Hi Michal. I really love this asset.

    This might be a longshot question. I'm not much of a coder.

    I have managed to put an array of Hexagonprefabs in to your HexGridGenerators and then randomly place these on the map.

    I have different prefab hexagons for grass, water, mountains etc. And i would love to have these in "clusters". Basically i want the hexagons randomly placed but i want "grass" to have a much higher percentage of being placed next to another "grass".
    Is this something you think would be doable?

    Also is there a way to use GetNeighbours to print out the neighbours of a selected cell?

    Thank you
     
  24. michal-zetkowski

    michal-zetkowski

    Joined:
    Mar 11, 2015
    Posts:
    282
    Hey, I'm happy to hear that you find my project useful :). What you're trying to do sound like procedural map generation. I've never done that so I won't be able to help you myself. There is plenty of resources on the topic in the Internet. Please find one of them in the link below. if you managed to generate map with random prefabs you're on the right track.

    https://www.redblobgames.com/maps/terrain-from-noise/

    Regarding your other question - the code below will print neighbours coords to the console and visualize them on the map. Replace these methods in CellGridStateUnitSelected.cs script.

    Code (CSharp):
    1.  
    2.         public virtual void OnCellDeselected(Cell cell)
    3.         {
    4.             cell.UnMark();
    5.             var neighbours = cell.GetNeighbours(_cellGrid.Cells);
    6.             foreach (var neighbour in neighbours)
    7.             {
    8.                 // This will unmark neighbours on the map
    9.                 neighbour.UnMark();
    10.             }
    11.         }
    12.  
    13.         public virtual void OnCellSelected(Cell cell)
    14.         {
    15.             cell.MarkAsHighlighted();
    16.  
    17.             var neighbours = cell.GetNeighbours(_cellGrid.Cells);
    18.             foreach(var neighbour in neighbours)
    19.             {
    20.                 // This will print neighbours coords to the Unity console
    21.                 Debug.Log(neighbour.OffsetCoord); //add using UnityEngine at the top of the file
    22.  
    23.                 // This will visualise neighbours on the map
    24.                 neighbour.MarkAsReachable();
    25.             }
    26.         }
     
    Last edited: Dec 15, 2019
    Diputs likes this.
  25. mauser100

    mauser100

    Joined:
    Oct 13, 2016
    Posts:
    13
    Hi,

    What's the best way to interrupt the highlighting of cell paths and of marking enemies as targets? I'm trying to implement something like xcom where you have to click a button to aim, which marks viable enemies and hides paths. So basically a toggle between only showing walking path or only showing targets in range.

    Thanks a lot
     
  26. michal-zetkowski

    michal-zetkowski

    Joined:
    Mar 11, 2015
    Posts:
    282
    Hey, could you provide some video from xcom where I can check out this feature?
     
    MyReazon likes this.
  27. mauser100

    mauser100

    Joined:
    Oct 13, 2016
    Posts:
    13
    Hey, uh yeah

    at about 0.56 you see that the player has a movement path indicated, then clicks on the fire mode and the camera changes and looks at eligible targets. Camera change is easy enough, as is switching between being able to move or shoot, just looking to interrupt the highlighting.
    Cheers
     
  28. michal-zetkowski

    michal-zetkowski

    Joined:
    Mar 11, 2015
    Posts:
    282
    Thanks, I get it now. In the framework highlighting reachable cells, paths and attackable enemy units happen in CellGridStateUnitSelected script. You need to split these functions into two CellGridState scripts and activate them accordingly (by activating I mean assigning the state to CellGrid.CellGridState field). Easier but dirtier option would be to just add some if statement to CellGridStateUnitSelected to display only paths or attackable units. I encourage you to look into CellGridState scripts yourself and get back to me when you have specific questions about implementation.
     
  29. mauser100

    mauser100

    Joined:
    Oct 13, 2016
    Posts:
    13
    awesome, thanks. Was struggling to follow where these functions were located.
     
  30. michal-zetkowski

    michal-zetkowski

    Joined:
    Mar 11, 2015
    Posts:
    282
    Hey,

    I wanted to let you all know that in a few days TBS Framework v2.0 will arrive in Unity Asset Store. Below I listed changes included in this release and a clip with a sneak peek of a new feature that was my main focus for this version - Tile Painter. Please note that since it is a major release it contains breaking changes. Check out documentation before upgrading your project. As for the plans for future, I would like to work on technical documentation and video tutorials that I get asked for frequently.

    I would like to take this opportunity to thank you for your support so far. The project would be long dead by now if not for you. Merry Christmas and a Happy New Year, I hope to hear from you soon :)

    Version 2.0
    -Added Tile Painter custom editor
    -Added Unit Painter custom editor
    -Added Prefab Helper custom editor
    -Added CameraController script
    -Added default value to MovementCost in Unit script
    -Added default value to ActionPoints in Unit script
    -Added default value to nHumanPlayers in GridHelper script
    -Added OnMoveFinished method to Unit script
    -Added CurrentUnit field to Cell script
    -Added new example scene
    -Added readme to example scenes
    -Added namespaces to code

    -Removed BreadthFirstSearch script
    -Removed GreedyBestFirstSearch script
    -Removed ListPriorityQueue script
    -Removed CustomObstacleGenerator script

    -Modified folder structure of the project for easier navigation
    -Changed MovementCost type to float
    -Changed ActionPoints type to float
    -Changed MovementSpeed to MovementAnimationSpeed
    -Changed MovementPoints to be accessible with getter
    -Changed ActionPoints to be accessible with getter

    -Maintaining cell prefab link when generating map
    -Centering camera on generated grid
    -Cell prefab is in XY plane now
    -Split DealDamage into AttackHandler, DealDamage and AttackActionPerformed methods
    -Split Defend into DefenceHandler, Defend and DefenceActionPerformed methods

     
    gferrari likes this.
  31. oldsnake90

    oldsnake90

    Joined:
    Dec 21, 2019
    Posts:
    2
    Ok dumb question im looking for something similar to a tactical gridbased battle system like Shining force. Where it is dependent upon the units Speed. Will i be able to modify this to do that. And also switch between battle mode and roaming towns?
     
  32. michal-zetkowski

    michal-zetkowski

    Joined:
    Mar 11, 2015
    Posts:
    282
    Hey,

    These are not dumb questions ;). The framework is not based on speed. It would be easy to modify it to use units based on their speed within a player, but I guess this is not what you are going for. To alternate between players would be significantly harder. If you write me in January after holidays maybe we can work something out.

    The framework only handles 'battle mode'. You would need to base your 'world roaming' mode on something else, and load scene done with the framework when player enters battle. It's been done before, you can check it out in Dust and Solt and Mortalaxy
     
  33. oldsnake90

    oldsnake90

    Joined:
    Dec 21, 2019
    Posts:
    2
    Thanks for replying yeah i can wait till January . But yeah if u can help me it would be amazing if u could help me. :) The reason why I'm making this is because i feel that the battle system disappeared in Shining Force games since the 90s so i wanna make a spiritual successor as a tribute. But yeah if u can help me i would be grateful:)
     
  34. Prescott_unity

    Prescott_unity

    Joined:
    Dec 28, 2019
    Posts:
    1
    Hey Michael,

    I'm looking to buy your framework, it looks great. Before I do, was wondering if you could point me in the direction of any threads about Fog of War? You mention in your FAQ that some other users have already explored some solutions. Wondering if I could peak in on any conversations around how other people have tackled this with your toolkit.

    Also, do you have any recommendations on how to implement scripted events (like sounds playing when units land on certain tiles). Is this something that would be implemented most simply with something like Play Maker?

    Thanks in advance!
     
  35. cplungis

    cplungis

    Joined:
    Sep 11, 2019
    Posts:
    6
    Hello,

    Wondering if anyone has tried to make transparent hexagon tiles. I have been working at it for several days and am still stumped. For some reason, my tiles are correctly transparent in both the scene and game tabs, but when I hit play, they are solid gray. The outline is correctly rendered in cutout. Here are some screen captures:
    upload_2020-1-1_10-56-33.png
    upload_2020-1-1_10-57-4.png
    upload_2020-1-1_11-4-9.png

    I have a top down orientation where z is north/south, x is east/west, and y is altitude using the 3D XZ plane and rectangular hex grid generator. My map underlay is at y = 0 and my hex grid is at y = 1. My hexes are 0.1 unit think in the z axis by scaling CellGrid's z component to 0.1. I have tried all different y values for each and have confirmed that my hexes are definitely above the map, so they do not extend through the map.

    fixedHexagon is based on the Hexagon prefab where the outline component of the original prefab was replaced by an open ended hexagonal pipe from blender, with it rendered in cutout. It behaves as intended.

    The "inside" of the hexagon the Cylinder 001 mesh with a new material, "Glass," set to transparent, albedo 0, Metallic Alpha and Albedo Alpha metallic and smoothness both set to 0 and 1.
    upload_2020-1-1_11-12-22.png
    upload_2020-1-1_11-12-51.png

    I think I've tried every combination of transparent, varying metallic and smoothness values, etc.
    Note, I cannot have the "inside" also rendered in cutout because the collider does not seem to work correctly and selecting a hex (for movement, unit placement, etc.) is only possible by clicking on the outline. Also, it still shows up as solid gray in play mode anyway.

    Any help would be appreciated!

    Thanks,

    Chuck
     
  36. michal-zetkowski

    michal-zetkowski

    Joined:
    Mar 11, 2015
    Posts:
    282
    Again, sorry for delayed reply. @cplungis - you are using MyHexagon script from example scenes code. The script changes color of cell in various states. To fix your issue just comment out SetColor method calls in the script. Let me know if you have further questions.
     
    Last edited: Jan 11, 2020
  37. war76mm

    war76mm

    Joined:
    Jan 20, 2020
    Posts:
    10
    Hi, are there limits on map size with your framework?
     
  38. michal-zetkowski

    michal-zetkowski

    Joined:
    Mar 11, 2015
    Posts:
    282
    Hey,

    There is no hardcoded limit, but performance will deteriorate with increasing map size and unit movement range. To try it out I put together a 100 x 100 map consisting of 3D hexagons, you can see screenshots with results below. When zoomed out I got about ~15fps and when I zoomed in it was ~60 fps. One thing to note is that it took about 30 seconds to start the level.

    scr1.png scr2.png
     
  39. takeuchihidekijp

    takeuchihidekijp

    Joined:
    Mar 2, 2018
    Posts:
    5
    Hello.
    I make games using this framework.
    In this game, Player and AI have their own bases, move to a specific position on the map while fighting, and return to your own base.
    In the game, if each character fights and one character loses, we are thinking about a mechanism that will be newly generated as a prisoner of war in the opponent's base.
    In this case, I want to erase the character once and place a new POW prefab somewhere on the map.
    What should I do if you use this framework?
     
  40. michal-zetkowski

    michal-zetkowski

    Joined:
    Mar 11, 2015
    Posts:
    282
    Hey,

    First you should intercept an event when unit dies (check out DefendHandler method in Unit.cs). Next you have two options: either remove the line where Unit is destroyed after dying and just move it to the oponent base (change its Cell field to the cell where the base is located) or destroy the unit and instantiate new POW unit. To add unit instantiated on runtime to the game, use AddUnit method from CellGrid class.

    Let me know if you have further questions.
     
    takeuchihidekijp likes this.
  41. takeuchihidekijp

    takeuchihidekijp

    Joined:
    Mar 2, 2018
    Posts:
    5
    Thank you for your reply.
    In this case, we want to destroy the opponent, and then add the instantiated POW unit to the game with CellGrid's AddUnit.
    For example, I'm thinking of listing the Pow and arranging it in a specific position as shown below. In such a case, how should I implement it with AddUnit?

    var ins = Instantiate (PowPrefab, new Vector3 (4, 2,), PowPrefab.transform.rotation);
    pows.Add (ins);
     
  42. michal-zetkowski

    michal-zetkowski

    Joined:
    Mar 11, 2015
    Posts:
    282
    Hey, try something like this:

    var ins = Instantiate (PowPrefab, new Vector3 (4, 2,), PowPrefab.transform.rotation);
    ins.GetComponent<Unit>().PlayerNumber = capturedUnit.PlayerNumber;
    ins.GetComponent<Unit>().Cell = someCell // Cell that belongs to "Pow camp"

    cellGrid.AddUnit(ins.transform);

    One thing to consider is if you want the POW to be interactable, or just a dummy. If you don't want to use that unit then set its ActionPoints to 0. I also assigned it a cell, but I guess that you could skip it. Let me know if you get any errors.
     
  43. ZDMGames

    ZDMGames

    Joined:
    Nov 6, 2019
    Posts:
    7
    Hello. Started a bit of a larger project earlier this week and was hoping to get some help on how to implement some changes. My game currently uses the 2D hex grid for an overworld. I need to make two main modifications right now and not sure the best way to do it. First, I need to disable attacking at the moment. Each unit is an army and I'll be implementing attacking again later so that it takes you to another scene where you command your army against the army you are attacking. The other thing I need to do is how to enable actions depending on the type of hex the army is on. I am making a town hex that allows the player to shop while at the town. What would be the best way to enable this action with the current system.
     
  44. michal-zetkowski

    michal-zetkowski

    Joined:
    Mar 11, 2015
    Posts:
    282
    Hey,

    Comment out below code in CellGridStateUnitSelected class in OnUnitClicked method:

    if (_unitsInRange.Contains(unit) && !_unit.IsMoving)
    {
    _unit.AttackHandler(unit);
    _cellGrid.CellGridState = new CellGridStateUnitSelected(_cellGrid, _unit);
    }

    This will disable attacking for human players. The AI works a bit different, you will need to modify NaiveAIPlayer script. Comment out unit.AttackHandler calls, that would be lines 52 and 114.

    Regarding your second question, I would again use CellGridStateUnitSelected script. As the name suggests, it is used when player selects a unit. In the script there is a methid OnStateEnter that you could use.

    The flow would be like this:
    1. Player clicks on a unit
    2. OnStateEnter in CellGridStateUnitSelected fires up
    3. Check what type of cell the unit is standing on (you have a reference to cell in Unit.Cell field)
    4. If the type of the cell is 'town', display appropriate options

    Let me know if you have further questions
     
  45. ZDMGames

    ZDMGames

    Joined:
    Nov 6, 2019
    Posts:
    7
    Thank you for the tip on getting the cell type. Luckily, I've managed to create an altered attack script for the Army Units to launch into the actual combat. I do need to create a custom game manager to handle some of the handshaking between scenes, but I know I'm doing with that. There is one last thing I could use some advice on that is a bit more advance. For the square-based system, I need to make modifications to allow some units to occupy multiple tiles. I have plans for larger units that take up a 2x2 area, like what you can find in Banner Saga or the newest Fire Emblem. You wouldn't happen to know where I should be looking to modify pathfinding and attack targeting for this, would you?
     
  46. michal-zetkowski

    michal-zetkowski

    Joined:
    Mar 11, 2015
    Posts:
    282
    Hey,

    So first of all, you would need to implement different pathfinding algorithm. Clearance based pathfinding, linked below, seems to be fine for this purpose. To include this new algorithm in the framework, you should implement IPathfinding class and assign it to _pathfinder and _fallbackPathfinder fields in Unit class (there might be some issues with this but let's worry about it later.

    Secondly, modify Move method in Unit class so that it sets 'IsTaken' field on each of the cell that it takes up instead of just one.

    Lastly, modify IsUnitAttackable method in Unit class to take this new situation into consideration.

    That is all that I can think of at the moment, let me know if you have further questions.

    https://harablog.wordpress.com/2009/01/29/clearance-based-pathfinding/
     
  47. ZDMGames

    ZDMGames

    Joined:
    Nov 6, 2019
    Posts:
    7
    Thank you. I give this a read and start hacking away at the system. One last thing that would be helpful to know. What would be the best way to pause the action on the board while a menu is up. I just about finished up a unit based inventory system and need to shut off things like unit actions, selection and deselection while the menu is open.
     
  48. michal-zetkowski

    michal-zetkowski

    Joined:
    Mar 11, 2015
    Posts:
    282
    To block user interaction while AI takes its turn I use CellGridStateAiTurn class. You can use it to effectively "pause" the game. Just assign CellGridStateAiTurn object to CellGrid.CellGridState
     
  49. jaycgolden

    jaycgolden

    Joined:
    Jul 19, 2019
    Posts:
    3
    hello, I am modifying my game which based on the Example 1. I want to change to walk animation when the unit is moving, I find the move function in myUnit.cs but even I set change animation before that function, it still appear movement before change the animation...what can I do...please help...I spent few day to modify and still don't understand it.... :(:(
     
  50. michal-zetkowski

    michal-zetkowski

    Joined:
    Mar 11, 2015
    Posts:
    282
    Hey, as far as I understand you want to add animation to your unit. I see that you are on the right track. In general, you should start your animation in Move() method of your unit, and stop it in OnMoveFinished() method. Could you describe in more detail what you did and what is wrong? Maybe you could show your code or record a clip?