Search Unity

[RELEASED] Turn Based Strategy Framework

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

  1. zacharylim96

    zacharylim96

    Joined:
    Jun 17, 2020
    Posts:
    1
    @michal-zetkowski

    Hi, I just bought the TBSF kit and I'm finding it of great use so far. I have run into two problems:

    1. I think your current implementation has only one int for HP, and it's kind of built into the system). I want to create a system where a unit has multiple HP bars for different "body parts", and destroying various body parts paralyzes a unit in some way.

    A good example is shown below in the following format:
    Unit: BodyPart1 (Destruction penalty1), BodyPart2 (Destruction penalty2), etc...

    a) Tank: Body (unit destruction), Treads (unit immobilization)
    b) Infantry Squad: Soldier1 (loss of 1/3 firepower), Soldier2 (loss of 1/3 firepower), Soldier3 (loss of 1/3 firepower)

    2. I want to create a custom attack where I calculate straight line LOS from the aggressor unit, and if the enemy unit is in cover, I have a 50 50 chance to attack either the enemy or the cover instead.

    3. The attack should augment the health bars as follows in this example:

    - infantry squad, strong vsPerson (does heavy damage to one enemy infantry's HP bar), weak vsArmor (light damage spread to all) tank's body parts

    IE.
    Tank --> Infantry Squad:
    Infantry Squad (Soldier1: 6, Soldier1: 6, Soldier1: 6) -> Infantry Squad (Soldier1: 5, Soldier1: 5, Soldier1: 5)

    Tank --> Tank:
    Tank (Body: 12, Treads: 12) -> Tank (Body: 6, Treads: 12)

    Infantry Squad --> Tank:
    Tank (Body: 12, Treads: 12) -> Tank (Body: 11, Treads: 11)

    Infantry Squad --> Infantry Squad:
    Infantry Squad (Soldier1: 6, Soldier1: 6, Soldier1: 6) -> Infantry Squad (Soldier1: 0, Soldier1: 6, Soldier1: 6)

    Do you have any idea how to implement this with the current system? I am currently checking up your backend and it seems the attack and HP system are too interconnected with the system and it is not easily modifiable.
     
  2. Untrustedlife

    Untrustedlife

    Joined:
    Apr 21, 2020
    Posts:
    78
    heh the stuff you are implementing is stuff ive already implemented in dr4x lol
     
    Liberation85 likes this.
  3. Untrustedlife

    Untrustedlife

    Joined:
    Apr 21, 2020
    Posts:
    78
    Its not ideal but simply going ctrl+r a couple times usually fixes the issue
     
  4. Untrustedlife

    Untrustedlife

    Joined:
    Apr 21, 2020
    Posts:
    78
    Very cool, I just color the tiles in the path but a line might look nicer heh.
     
    Liberation85 likes this.
  5. michal-zetkowski

    michal-zetkowski

    Joined:
    Mar 11, 2015
    Posts:
    282
    Hey, thanks for buying :) I have some general tips for you:

    1. I would represent each unit part as a separate script (you would store HP and encapsulate destruction effect in the script).
    2. Attach a collider to each part and make them children of your unit
    3. This way Unit will register a callback when any part is clicked on - attacked for example
    4. Overwrite DefendHandler method in your Unit class to direct the damage to specific part, BUT you'll need to make DefendHandler method virtual in Unit AND extend its parameters to pass the part that was actually attacked (you'll need it to pass this information from "Part" script - or set a flag on "Part" and query all parts to check which was clicked in DefendHandler - up to you)

    As for line of sight attack, damage is calculated in DealDamage method. Overwrite it, decide if unit is in line of sight and assign the damage.

    Lastly, I would check type of attacking unit in overwriten DefendHandler method and distribute the damage accordingly.

    Let me know if you have further questions :)
     
  6. michal-zetkowski

    michal-zetkowski

    Joined:
    Mar 11, 2015
    Posts:
    282
    Yes, our discussion from some time ago inspired me to implement structures like cities and bases as units :) Works pretty good.
     
    Untrustedlife likes this.
  7. Megalogue1

    Megalogue1

    Joined:
    Dec 17, 2020
    Posts:
    134
    Hopefully a quick question: suppose a player wants to move a unit to a certain cell. For the unit and cell in question, IsCellMovableTo returns true, but IsCellTraversable returns false. Should the unit be able to move to the cell in this situation?

    A shorter version of the question would be: does a cell have to be traversable in order to move to it? So far it seems like the answer is yes, but maybe there's something wrong with my tests.

    EDIT: It might be more productive to describe exactly what I'm going for. Basically, I want the situation in the below illustration to be possible. The unit can move to all cells marked with M, and move through any cells marked with T. Note that the traversable cells are in a "U" shape, and the unit should NOT be able to move through the blank area in the middle of the "U".

    It seems like this is what you were going for with the terms "movable to" and "traversable," but again, in my tests, it seems like if a cell isn't traversable, it's also impossible to move to it.

    https://drive.google.com/file/d/1zaghlt4Z315e83OFo9bvHQ-wjLcdjUV_/view?usp=sharing
     
    Last edited: Oct 25, 2021
  8. michal-zetkowski

    michal-zetkowski

    Joined:
    Mar 11, 2015
    Posts:
    282
    Hey, the short answer is yes, a cell have to be traversable in order to move to it :) (well, thats from the top of my head, can't test it at the moment but I'm pretty sure that's the case)

    I studied your sample and I "think" I know what you're trying to get. Let's say "T,M" cells are water, "M" cells are hmm, "slots", "docks", "bays"? Basically a safe spot for ships. Ships can move freely on water and finish their move in a dock. It should not be possible to move directly from dock to dock. is that right? I'm interested in your use case.

    If that is the case you can solve it by overwriting "GetNeighbours" method in your derieved Cell class. Simply add a field "isDock" to your Cell and check for it in GetNeighbours method. If a given cell is a dock, then it should not include other docks in its neighbours list.

    The downside to this is that if you added another type of unit, let's say an airplane, then it would also not be able to move between docks (which should be possible as a plane). This would be harder to solve, you would either need to modify IsTraversable/IsMovable system or have GetNeighbours method accept unit as parameter or move GetNeighbours to Unit altogether. It does not seem like a big deal, but I guess it would break some optimization tricks that I included in the framework. Anyway, interesting use case, I will consider it.

    Let me know if that helped.
     
  9. Megalogue1

    Megalogue1

    Joined:
    Dec 17, 2020
    Posts:
    134
    I'm actually trying to replicate the territory capturing system from mobile games like Antiyoy and Island Empire. Here are some screenshots from Antiyoy to demonstrate. (Ignore the fact that it uses hexes; the principles are the same on any grid shape.) The first one gives you a full view of red's territory. Like in my previous illustration, it's kind of a "U" shape, for demonstration purposes. The second one shows you the territory-based movement constraints.

    As you can see, the unit's maximum movement range is 4, but it can't move 4 spaces across neutral territory, even if the destination is another part of its own territory. No unit can ever move more than 1 space outside of its own territory in one turn. Once it moves there, the space is captured, and becomes part of the player's territory.

    https://drive.google.com/file/d/1zKr-ADlSFsTphijyKmLuKLxN7UwlXk6X/view?usp=sharing
    https://drive.google.com/file/d/1zJFvLaSMB7vsPK61ah9h7ruztvnpUdS4/view?usp=sharing

    I already have a territory system working. It uses a node graph that keeps track of one node for each cell of the board. The system can detect interconnected regions and their sizes, and whether a given node is part of a region or adjacent to a region. I was working on pairing this system with your framework when I ran into the "traversable/movable" to conflict.

    Just to summarize, here's what I want to achieve:
    • Nodes that are part of the unit's current territory region are both traversable AND movable to.
    • Nodes that are not part of the unit's current territory region, but instead are adjacent to the region, are movable to, but NOT traversable.
    • Nodes that are not part of the unit's current territory region and are not adjacent to the region are not movable to OR traversable.
    Any advice on how to achieve this in conjunction with your framework is greatly appreciated. :)
     
    Last edited: Oct 25, 2021
  10. michal-zetkowski

    michal-zetkowski

    Joined:
    Mar 11, 2015
    Posts:
    282
    Ok, I get it. I looked into the framework and I think you need to go deeper than just IsCellTraversable and IsCellMovableTo.

    Take a look at Unit.GetAvailableDestinations. That's the one that validates paths and returns cells that the unit can move to. You could use it to add your own validaiton - check if path is not through enemy territory. The only issue is that the method is not virtual, but feel free to make it.

    BTW, there actually is a method that would solve the example with ships and airplanes that I described, GetGraphEdges. Good job myself from 2015! You might also find it useful.

    I don't have time to implement it myself, but I guess that mix of IsCellTraversable, IsCellMovalbeTo, GetAvailableDestinations and perhaps GetGraphEdges should get the job done.

    Let me know how it turned out.
     
    Megalogue1 likes this.
  11. Megalogue1

    Megalogue1

    Joined:
    Dec 17, 2020
    Posts:
    134
    As a new programmer, I don't fully understand some of your code, but I took a shot at it anyway. I made the method virtual and created an override in my CustomUnit class. For now I just pasted all of the base code in there, with the addition of a call to my custom validation method (seen in line 8).

    Code (CSharp):
    1.     public override HashSet<Cell> GetAvailableDestinations(List<Cell> cells)
    2.     {
    3.         cachedPaths = new Dictionary<Cell, List<Cell>>();
    4.  
    5.         var paths = CachePaths(cells);
    6.         foreach (var key in paths.Keys)
    7.         {
    8.             if (!IsCellMovableTo(key) || (movementSO != null && !movementSO.TryValidatePath(paths[key], this, key, refs)))
    9.             {
    10.                 continue;
    11.             }
    12.             var path = paths[key];
    13.  
    14.             var pathCost = path.Sum(c => c.MovementCost);
    15.             if (pathCost <= MovementPoints)
    16.             {
    17.                 cachedPaths.Add(key, path);
    18.             }
    19.         }
    20.         return new HashSet<Cell>(cachedPaths.Keys);
    21.     }
    22.  
    And the TryValidatePath method:
    Code (CSharp):
    1.     public bool TryValidatePath(List<Cell> pathCells, CustomUnit unit, Cell destinationCell, ServiceReferences refs)
    2.     {
    3.         for (int i = 0; i < pathCells.Count; i++)
    4.         {
    5.             if (pathCells[i] == destinationCell)
    6.                 continue;
    7.  
    8.             Vector2Int coords = new Vector2Int((int)pathCells[i].OffsetCoord.x, (int)pathCells[i].OffsetCoord.y);
    9.             int territoryInt = refs.TerritoryHandler.GetTerritoryIntAt(coords.x, coords.y);
    10.             if (territoryInt != unit.PlayerNumber)
    11.                 return false;
    12.         }
    13.         return true;
    14.     }
    It's not working right, as you can see in this screenshot:
    https://drive.google.com/file/d/14tFxKTw3MZnrpa0b5DthXfl9ctD5DkYn/view?usp=sharing
    Blue is the unit's territory. The unit is selected, and green-tinted cells are those it can move to. (If you look closely the some of the territory cells are also slightly green-tinted.) As you can see, the available destinations are very sparse and inconsistent.

    I think what's happening here is that the pathfinding is calculating paths, and then my validation comes in and removes some of them (specifically, any that have more than one cell outside friendly territory). When these are removed, they aren't replaced with new paths. So the missing options we're seeing are options for which the pathfinding calculated a path that failed my validation.

    I'm starting to think I have to go even deeper, into the pathfinding algorithms themselves, to force the pathfinder to only calculate paths that conform to my rules. Of course, I'd like to avoid this if possible, because simpler solutions are always better. Is there some simpler way I'm missing here?
     
  12. michal-zetkowski

    michal-zetkowski

    Joined:
    Mar 11, 2015
    Posts:
    282
    Could you export the project and send it by email to crookedhead@outlook.com? I'll take a look
     
  13. Megalogue1

    Megalogue1

    Joined:
    Dec 17, 2020
    Posts:
    134
    Sure thing, the email is on its way.
     
  14. Untrustedlife

    Untrustedlife

    Joined:
    Apr 21, 2020
    Posts:
    78
    Hey there michal-zetkowski, i have a bit of a problem.
    Im operating on a old version of the framework and i've made a lot of changes to it on my end so id rather not update. Would it be possible for you to get me the newer ai pathfinding code. I'm running into a significant hurdle here on medium map (50x50) where enemy turns are taking like 3 minutes once they have a significant amount of the map explored it is basically unplayable at that point.
    They path within their explored cells. So its artificially limited that way. But even with this limitation I have an AI player here who has explored about half the map and well it just kills the pathfinding heh.
    I could make them sort by nearest so that they always target the nearest units, but the enemy unit sorting is taking into account a lot of stuff (eg, whether the unit is a good counter etc) so sorting by nearest only would make them play sub par.
     
    Last edited: Nov 1, 2021
  15. Untrustedlife

    Untrustedlife

    Joined:
    Apr 21, 2020
    Posts:
    78
    I'll eventually just separate my grids into quadrants to reduce the impact of stuff, but i think i saw you a few months back saying you were able to optimize it quite a bit?
     
  16. Untrustedlife

    Untrustedlife

    Joined:
    Apr 21, 2020
    Posts:
    78
    Also it is indeed the pathfinding, because clearing the list of explored tiles completely for all enemy players (in this case 6 of em) and running a turn (which effectively reduces the pathing area to like 1 hundredth) makes the turn only take 20 something seconds in the late game which isn't too bad imo.
    But 3 minutes with half the map explored, makes the game entirely unplayable at that point heh
    (Separating the explored tile list into quadrants will likely resolve this mostly, but if i dont need to do that it would be more ideal)
    The other option would be implementing:
    HPA* (Hierarchical Path A*)

    Or if you have any ideas that I can implement in the pathfinding code to make things run faster. Though looking through the code nothing obvious jumps out (no getcomponent calls to cache, etc)

    By the way I am on 2.0 , not 2.0.1
     
    Last edited: Nov 1, 2021
  17. Untrustedlife

    Untrustedlife

    Joined:
    Apr 21, 2020
    Posts:
    78
    Oof, maybe i should just ditch all the changes ive made to the ai and bite the bullet and update
     
  18. Untrustedlife

    Untrustedlife

    Joined:
    Apr 21, 2020
    Posts:
    78
    I found a solution, I just made the cache paths the AI uses just cache all paths within their explore that are movable to. They still care about movement costs because I check in the code whether the path cost works with the unit before moving. But just creating all the paths and caching them brought 3-4 minutes down to like 12 seconds damn.
    And I think its still choosing the most efficient path? At least from some tests I did.
     
    Last edited: Nov 1, 2021
  19. michal-zetkowski

    michal-zetkowski

    Joined:
    Mar 11, 2015
    Posts:
    282
    Hey @Untrustedlife, sorry for the delay, I was away. The update that is coming does not include any pathfinding optimizations. The AI in general is reworked. It doesn't mean that it will automatically perform better, but it will be neatly separated and it will be easier to find the bottleneck.

    That being said, I think that there is a lot of room for mico-optimization in the Framework, but I guess it is project-specific. In your case, did you consider pre-calculating all the paths as part of level loading (or even saving paths to some file?) Ofc you would need to check if path is valid on runtime (there could be a unit in the way), but most of the paths should be ok (?). Let me know if you think this is fesible and how it worked out for you.

    Also, thanks for pointing out HPA*, I'll check it out.
     
  20. Megalogue1

    Megalogue1

    Joined:
    Dec 17, 2020
    Posts:
    134
    Hey, I'm back :) Hopefully this is an easy question.

    When a friendly unit is selected, and you click a cell that unit can't reach, the unit becomes de-selected. I would like certain other actions the player takes (such as clicking a UI button) to also de-select units. How can I do this through code?

    I took a look around the existing TBS code and I think it has something to do with cell and/or unit states, but I don't really understand how those work.
     
  21. michal-zetkowski

    michal-zetkowski

    Joined:
    Mar 11, 2015
    Posts:
    282
    Yes, that's easy. Just set new CellGridStateWaitingForInput to CellGrid.GridState :)
     
    Megalogue1 likes this.
  22. id0

    id0

    Joined:
    Nov 23, 2012
    Posts:
    455
    Hello. I have a question. Now difficult make some tiles make passable for one unit type, and impassable for others? For example I want flying enemies ignore the rocks or water (but not trees), but other units not.
     
  23. michal-zetkowski

    michal-zetkowski

    Joined:
    Mar 11, 2015
    Posts:
    282
    Most certainly, check out Example2 scene. There are "Flying saucer" units that can move over water (but not end their movement over water), and basic ground aliens that only move on ground.

    Link to demo scene below:
    https://crookedhead.itch.io/turn-based-strategy-framework-demo-3
     
    id0 likes this.
  24. id0

    id0

    Joined:
    Nov 23, 2012
    Posts:
    455
    Thanks for the answer. But how ignore tile cost in flying units?
     
  25. unity_58732F505F5BF08ACE21

    unity_58732F505F5BF08ACE21

    Joined:
    Nov 10, 2021
    Posts:
    1
    Hello, which AI plugins do you recommend for a scripted AI like having a script for a battle and we want units to have a scripted behavior like moving forward, retreating after some turns, focus on a certain character or changing behavior after some time or by a trigger.
    there are many solutions like behavior designer, node canvas, RV Smart AI. which plugins do you mostly recommend who are capable of doing this scripted behavior.
     
  26. id0

    id0

    Joined:
    Nov 23, 2012
    Posts:
    455
    Hello again. I made a flying unit, but it only flies over obstacles. I tried to do this:

    Code (CSharp):
    1.         public override bool IsCellMovableTo(Cell cell){
    2.      
    3.             if(flying)
    4.                 return !(cell as MySweetHexagon).IsSkyTaken;
    5.  
    6.             return !cell.IsTaken;
    7.         }
    Now I can click on cell, but nothing happen, because I need to edit OnCellClicked method. I tried to make reference like this:

    Code (CSharp):
    1.         private void OnGameStarted(object sender, EventArgs e)
    2.         {
    3.             foreach (Transform cell in CellGrid.transform)
    4.             {
    5.                 cell.GetComponent<Cell>().CellClicked += OnCellClicked;
    6.                 cell.GetComponent<Cell>().CellHighlighted += OnCellHighlighted;
    7.                 cell.GetComponent<Cell>().CellDehighlighted += OnCellDehighlighted;
    8.             }
    9.  
    10.             OnTurnEnded(sender, e);
    11.         }
    But I have this error:

    Code (CSharp):
    1. error CS0123: No overload for 'OnCellClicked' matches delegate 'EventHandler'
    P.S. And again, how to ignore tile cost (only for this unit)?
     
    Last edited: Nov 11, 2021
  27. michal-zetkowski

    michal-zetkowski

    Joined:
    Mar 11, 2015
    Posts:
    282
    To ignore cell movement cost you would need to overwrite Unit.GetGraphEdges method. In this method cost of moving between cells is defined.

    The error says that you handler method (OnCellClicked) does not match event type. It needs to have the following signature:

    void OnCellClicked(object sender, EventArgs e)
     
    id0 likes this.
  28. michal-zetkowski

    michal-zetkowski

    Joined:
    Mar 11, 2015
    Posts:
    282
    Can't really recomment any of them because I never used them. A new AI system is coming to the framework in next release though, you can read about it here:
    https://forum.unity.com/threads/released-turn-based-strategy-framework.704129/page-8#post-7164187
     
  29. Neil2TheKing

    Neil2TheKing

    Joined:
    Sep 14, 2017
    Posts:
    15
    Got the online version of the project up and running. You can now play the Turn Based Strategy Framework with online multiplayer. Here is a link to the demo: https://storytime.itch.io/tbs-framework-online-demo .

    Michal what's your email? I'll send you a zipped version of the project. Or if you have a github I'll commit it there so you have it for reference.
     
    Rootbeard, michal-zetkowski and aweha like this.
  30. id0

    id0

    Joined:
    Nov 23, 2012
    Posts:
    455
    It's me again. I made a unit, that explodes(and damages other units). One problem: if there is only one on the map, and it is destroyed, the game does not check for game over or something, the game just continues. How co check it? Please example?
    And if it's exploded, and kill last unit, how to check it also and make some "Draw"?

    Here is my code:
    Code (CSharp):
    1.         private void SpecialAbility()
    2.         {
    3.             //Destroy(gameObject);
    4.             if(!_abilityUsed)
    5.             {
    6.                 _abilityUsed = true;
    7.                 _specialAbilityButton.gameObject.SetActive(false);
    8.  
    9.                 if(explosion)
    10.                     Instantiate(explosion, transform.position, transform.rotation);
    11.                 _specialAbilityButton.gameObject.SetActive(false);
    12.              
    13.                 var cells = new List<Cell>();
    14.                 var neighbours = Cell.GetNeighbours(cells);
    15.  
    16.                 foreach(var neighbour in neighbours)
    17.                 {
    18.                     Debug.Log(neighbour.gameObject);
    19.                     if(neighbour.IsTaken){
    20.                      
    21.                         Unit unit = neighbour.CurrentUnit;
    22.                         AttackAction attackAction = DealDamage(unit);
    23.                         MarkAsAttacking(unit);
    24.                         unit.DefendHandler(this, explosionDamage);
    25.                     }
    26.                 }
    27.                 Cell.IsTaken = false;
    28.                 CellGrid _cellGrid = FindObjectOfType<CellGrid>();
    29.                 //_cellGrid.CellGridState = CellGrid.CellGridStateWaitingForInput;
    30.                 _cellGrid.CellGridState = new CellGridStateWaitingForInput(_cellGrid);
    31.                 MarkAsDestroyed();
    32.                 OnDestroyed();
    33.                 _cellGrid.Units.Remove(this);
    34.                 //CheckCondition(_cellGrid);
    35.             }
    36.         }
     
  31. michal-zetkowski

    michal-zetkowski

    Joined:
    Mar 11, 2015
    Posts:
    282
    Thanks a lot :D. My email is crookedhead@outlook.com it will be really helpful if you could share the project :)
     
  32. Liberation85

    Liberation85

    Joined:
    Apr 16, 2019
    Posts:
    65
    @michal-zetkowski Any eta for the new version?

    I've decided to do a bit of a rewrite since my coding has improved alot over the last year, but want to wait for the next version :)
     
  33. michal-zetkowski

    michal-zetkowski

    Joined:
    Mar 11, 2015
    Posts:
    282
    Hey, the release is still scheduled for Autumn
     
    Liberation85 likes this.
  34. michal-zetkowski

    michal-zetkowski

    Joined:
    Mar 11, 2015
    Posts:
    282
    Hey, what do you mean by "there is only one on the map"? One unit from the beggining of the game?

    The game over condition is checked in CellGrid.OnUnitDestroyed method. It gets called after any unit dies. If you wanted to check for draw then you neet to figure out a different trigger for game over check (on turn end? add event to your explosion and check condition when it is raised?)
     
  35. id0

    id0

    Joined:
    Nov 23, 2012
    Posts:
    455
    Yeah, but for some reason I call OnDestroy, and else, and stll game not check his dead instantly. No matter, I already make it other way. Thanks for the answer.
     
  36. Neil2TheKing

    Neil2TheKing

    Joined:
    Sep 14, 2017
    Posts:
    15
    BTW here are the scripts you need to set up online multiplayer. Attach the OnlineGameSetup script to a new gameobject in your main menu scene. Add the LoadOnlinePlayers to your Players gameObject and the CellGridOnline script to the CellGrid gameobject in your gameplay scene. Also attach a PhotonView component to all three of these gameobjects.

    You'll need to download PUN 2 from the Unity Asset Store and create a Photon account on Photon's website here: https://www.photonengine.com/

    Also check out post 399 for additional setup instructions
     

    Attached Files:

  37. brittany

    brittany

    Joined:
    Feb 26, 2013
    Posts:
    93
    I have just begun working with the framework and I am super impressed! The documentation is great and I appreciated the tutorial at the end, it really helped me understand how to actually get started from scratch. I have read about the features in the upcoming update in this thread and that is also very exciting!

    Most things I have been able to figure out myself using the documentation but I have a couple questions.
    1. How can I stop other things from happening (moving other units, ending turn, etc) until my attack sequence for the current unit (started in MarkAsAttacking) is completed?
    2. If I launch a projectile, meaning I actually send a collider with physics to hit another object, in the OnCollisionEnter method of the hit Unit, can I call a method to deal damage to that Unit?
     
  38. michal-zetkowski

    michal-zetkowski

    Joined:
    Mar 11, 2015
    Posts:
    282
    Thanks, it's always nice to hear that people find it useful :)

    1. Actually I just recently came across similar issue. The solution was to implement Abilities as coroutines and only "go forward" once the coroutine ends. So in the update this will be built-in, and for now your best option is to replicate it. In this particular case, maybe make AttackHandler a coroutine? In the coroutine you would use yield return new WaitForSecond(animationTime) to wait for the animation to end.

    2. This is kind of bypassing the framework, but I see no reason why it wouldn't work

    Let me know if you have more questions
     
    brittany likes this.
  39. brittany

    brittany

    Joined:
    Feb 26, 2013
    Posts:
    93
    I was wondering if the framework supplied a method that I could call to deal damage within the framework. Something already in the API. I am having trouble figuring out when damage is dealt and how it works in the framework. Maybe if I could figure out the process the framework uses to deal damage, I could just add a bit of code to let me trigger it when I want and not break things. If I go around it and deal damage directly I'm worried I might break things because there are other things going on, like what if I kill an enemy and the framework doesn't register it, or what if the supplied methods are not called like MarkAsDefending and so on. I don't want to bypass all that stuff I just want to be able to trigger that whole process on a collision instead of whenever it is currently triggered. I'm looking for a way to deal damage but still have it fit in with the framework.

    edit: here are some reasons I wanted to do it this way, which may help because I might be thinking weirdly:
    I could easily have the damage reaction animation and reduction of hit points be displayed timed right after the unit is hit by the projectile.
    I could easily do area of effect attacks.
    It would make it easy to do, for example, a giant slash attack from a boss that hits in a wide arc hitting multiple player units

    I'm brand new to the framework so I may be thinking of things in a mixed up way, I admit
     
    Last edited: Nov 21, 2021
  40. michal-zetkowski

    michal-zetkowski

    Joined:
    Mar 11, 2015
    Posts:
    282
    Hey, I just released a new demo scene for the upcoming update. I hoped it would turn out better, but it gets the job done in showcasing some of the new features. Anyway, I need to move forward with the update so it is what it is for now. Check out description on itch.io for more information. Enjoy!

    https://crookedhead.itch.io/homm-demo

    (BTW, my friend found a bug in Lightning spell but I couldn't reproduce it. Watch out for that)
     
    Last edited: Nov 22, 2021
    mygskrh, Liberation85 and brittany like this.
  41. michal-zetkowski

    michal-zetkowski

    Joined:
    Mar 11, 2015
    Posts:
    282
    Ah, sorry, you were asking what method to call to deal damage. That would be "AttackHandler" on the attacking unit, with target unit as the parameter. Check it out to figure out what is going on.

    Regarding your resoning - I might be biased, but I would encourage you to think in terms of the Framework. While using colliders to implement area of effect attack could work, it makes more sense to just calculate what cells / units are affected using tools provided by the framework (to be specific: every unit has a reference to its cell in Unit.Cell field. You can then calculate other affected cells by checking if they are within attack radiius - all cells are stored in CellGrid.Cells field).

    (BTW, check my previous post with a link to a new demo scene, there is a Fireball spell implemented that cause area of effect damage)

    As for playing the animation when projectile hits unit - this will still need to be asynchronous somehow. So either way, you need to introduce coroutines somewhere.

    Let me know if you have more questions.
     
    aweha and brittany like this.
  42. brittany

    brittany

    Joined:
    Feb 26, 2013
    Posts:
    93
    Thank you so much for your help and advice about using the framework. Well, I really would like to do things in a way that are most fitting for the intentions of how the framework is meant to be used. It would probably work best and, if I get into trouble I can get advice from you or the community if I am doing things that way :)

    I played the new demo and it is very cool! The new update is going to be awesome. I am going to work on graphics (there is so much to do) and wait until I get the new update and start trying to implement things and see if I have any more questions or need any advice then.

    But thank you so much for your help! I really appreciate it.
     
    michal-zetkowski likes this.
  43. Driskiie

    Driskiie

    Joined:
    Nov 23, 2021
    Posts:
    2
    Hey man this is an awesome framework and its a great design my teacher has thoroughly enjoyed but we have run into some problems, we are trying to figure out how make this game a playable XR experience, for the OnMouseClick Method to be called with a Raycast tracked device and being able to interact in the scene we have been trying for a few days and haven't been able to figure it out, just wondering if you've had any ideas on how to get the unit selection in Raycast to work! Thank you!
     
  44. michal-zetkowski

    michal-zetkowski

    Joined:
    Mar 11, 2015
    Posts:
    282
    Sure, what exactly did you try, what are you stuck on? I assume you are using one of the demo scenes, right? If not, do you have colliders on your Units / Cells? Raycasting should get you all the colliders that the ray goes through, once you have it, it should be just a matter of calling Unit.OnMouseDown method.
     
  45. Driskiie

    Driskiie

    Joined:
    Nov 23, 2021
    Posts:
    2
    ( The issues that I am having is that with the main camera running I am able to use my mouse click and move units and end the turn, but when I Put on the VR headset to try and interact with the objects nothing happens and its like the Raycasts don't even care that they have hit the colliders. )

    My teacher is even stumped why and we have been looking over the documentation, so am I going to have to write a script that realizes with the raycasts hit they they should use on mouse click or is that already a basic concept with raycasts. I apricate you helping out I'm only 4 months in to using unity and I have not been able to find an answer even after scouring the internet for hours.
     
  46. michal-zetkowski

    michal-zetkowski

    Joined:
    Mar 11, 2015
    Posts:
    282
    Sorry for the delay.

    Ok, so I have no experience with developing for VR whatsoever. As I understand, you are trying to make functions like OnMouseDown wirk with the headset, right? You're not casting any rays yourselves? Frankly speaking, I don't know how to help. Googling "unity vr onmousedown" gives some results, It's worth checking it out (but I assume you googled it already)

    I'll be happy to help if you have any specific questions regarding the framework
     
  47. Untrustedlife

    Untrustedlife

    Joined:
    Apr 21, 2020
    Posts:
    78
    Impressive. Maybe i could retroactively add MP to dr4x hmmmm
     
    michal-zetkowski likes this.
  48. Scynoth

    Scynoth

    Joined:
    Apr 25, 2016
    Posts:
    10
    Bought this asset a while back but never had a chance to use it. I see now that you're working on an updated version that's slated for a Autumn release. Just wondering if you had an update on that timeline, excited for some of the new features you're adding.


    Thanks!!
     
    michal-zetkowski likes this.
  49. Artyom203459

    Artyom203459

    Joined:
    Oct 5, 2021
    Posts:
    2
    One question, it's winter now and I'm wondering how long it will probably be before the update to the framework is available. I've seen the new demo level and the new features in the demo happen to meet most of my development needs, so I'm kind of anxious to use the framework update.:)
     
    michal-zetkowski likes this.
  50. michal-zetkowski

    michal-zetkowski

    Joined:
    Mar 11, 2015
    Posts:
    282
    @Scynoth @Artyom203459 I know it's snowing already, but actually winter starts on December 21st ;) The status is that I go through the code every day, do very minor fixes, started updating the documentation and I'm commited to release it before Autumn ends :)