Search Unity

TurnBased-Toolkit (TBTK)

Discussion in 'Assets and Asset Store' started by Song_Tan, Aug 11, 2013.

  1. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    Are you using Unit2019? I have someone telling me that adding the unit via editor is not working in Unity2019 (the changes are not being saved). So if you are using Unity2019, you probably want to switch back to 2018 for now.

    When you say you add the unit manually, do you mean you add the prefab to the UnitDB in Resources/DB_TBTK manually? If you do that, you have to make sure that all the unit prefabs has a unique value for prefabID. Otherwise prefab with duplicate prefabID won't show up properly in the editors.
     
  2. Capo_291

    Capo_291

    Joined:
    Jan 17, 2019
    Posts:
    12
    I'm using 2018.3.1 the unit saves, but if I make any changes to the prefab of the unit, for example if I change their scale to make them a little bit bigger, then the unit disappears from the unit editor.
     
  3. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    That doesn't sound right to me. So just to confirm: You create a new unit prefab, add it to the editor, saved. Now as soon as you change the scale value of the prefab, it's gone from the editor? Does it happen consistently? I have to say I don't have the problem but I do notice other issue, probably due to import error from the package from earlier version of unity. I'll look it up but I don't think that has anything to do with your problem. Can you find out exactly what is the step to get the added prefab removed from the editor. That would help tremendously.
     
  4. Capo_291

    Capo_291

    Joined:
    Jan 17, 2019
    Posts:
    12
    Yes that's correct. It does happen consistently. If I increase the scale or change any part of the prefab after I open the prefab it will disappear from the editor.
    Thanks for the quick feedback and the asset, it is really great and I can tell you put a lot of work into it.
     
  5. Capo_291

    Capo_291

    Joined:
    Jan 17, 2019
    Posts:
    12
    Also just to confirm I have the script UnitDB but I do not have UnitTB. I have been adding Unit (script) Unit (audio) script and Unit (animation) script to my units by copy paste. Or I have just been copying an existing prefab like the UnitRTank1 and then making a new unit based off of the copied prefab. I don't know if it is my process that is causing problems or what.
    In your tutorial video you drag the UnitTB file over to the unit you are creating, but I don't have that file I have looked through the files and I have searched for UnitTB with the search bar.
    I'm not sure what I should do, collectibles, units, abilities, will disappear and I'm unable to make any progress.
     
  6. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    Sorry for the slow respond.

    Apparently I've been out of the loop. I wasn't aware that Unity2018.3 has a entirely new and different prefab workflow thanks to the nested prefab. Apparently that breaks all the custom editor of TBTK. Which explain all the problem you are experiencing. I'm trying to resolve this asap. But honestly this is not a trivial task and it might take some time. I would suggest you to use TBTK with Unity2018.2 (or any earlier version) for now.

    Fyi UnitTB is for older version of TBTK. the current version is using Unit.

    Also, I'm working on a brand new, much improved version of TBTK which hopefully will be available in a few weeks. Unfortunately it won't be backward compatible and it will be a paid upgrade. If you are interested in that, I would recommend you to wait.

    I'm very sorry for the inconvenience.
     
  7. Capo_291

    Capo_291

    Joined:
    Jan 17, 2019
    Posts:
    12
    That sounds great I'll change to the older version of Unity. I recently purchased this one, will it be cheaper for those that own TBTK? Thanks for your quick response.
     
  8. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    It will definitely be cheaper for those that has purchased TBTK in the past. I haven't decided the final price yet. But it should be around $10 to $15.
     
  9. VFXROB

    VFXROB

    Joined:
    May 4, 2015
    Posts:
    27
    Hi Song, sorry for the slow reply i was trying to figure it out but having no luck.

    Yeah its a consistent bug.

    I thought initially i had broken it when removing the dead bodies by disabling

    //Destroy(thisObj);

    the last line of code in (dead)) to keep the dead bodies but i turned that back on and it still seems to be doing it with the below error.

    MissingReferenceException: The object of type 'Unit' has been destroyed but you are still trying to access it.
    Your script should either check if it is null or you should not destroy the object.
    TBTK.AIManager+<FactionRoutine>d__12.MoveNext () (at Assets/TBTK/Scripts/AIManager.cs:66)
    UnityEngine.SetupCoroutine.InvokeMoveNext (System.Collections.IEnumerator enumerator, System.IntPtr returnValueAddress) (at C:/buildslave/unity/build/Runtime/Export/Coroutines.cs:17)



    Just reading up on the above problem. A work around is do any edits in the inspector before adding the unit to the editor. If the editor is blank restarting or clicking play seems to refresh it.

    Also pretty excited about hearing about a new updated version, do you think it be released within a month? Just tossing up whether to also wait and use my current project to just keep getting familiar with the kit.
     
  10. Tarrasque

    Tarrasque

    Joined:
    Jan 5, 2015
    Posts:
    21
    Hi songtan, thanks for the amazing kit! I have few questions:

    - can you already tell which features will come with the new update?

    - I´m having a problem that some units move too far? So when select a square for a creature to move it moves further even outside of the grid. Is this also related to Unity 2018.3?
     
  11. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    @VFXROB, So there's an error. Now I see what could have possibly cause this. Try modified line69 of AIManager to this: if(unitList==null || unitList.HP<=0) break;

    @Tarrasque, I don't think the unit overshoot problem is related to Unity2018.3. Are you using animation? Do the unit stick to the grid or it look as if they no longer centered on the tile? If they start at the center of the tile when not moving but stray off as soon as they move, it could be due to your animation carrying the model of the unit off their origin position. In that case, you will need to disable the apply-root-motion flag on the Animator component. If this is not the cause, I'm not really sure what could have gone wrong. Do you have any video, or images to illustrate the problem?

    Regarding the new version, I'm not sure when it will be ready. I'm probably a week or two away from completing it. However once I submit it, there's no telling how long will it takes for the AssetStore team to approve it. Beside, this new prefab workflow with 2018.3 and upcoming 2019 has throw me off my track a bit. I'll have to fix all my existing package before I can carry on working.

    What I can tell you is the features:
    • Major restructuring to allow more configuration. There will be a new effect system where you can create and customize effects. The effects are stats block to modify the basic unit stats as well as adding various status. These effects can be attached to ability or basic-attacks.
    • There will be more clarity on how the stats works too. Basically they can be set as multiplier or modifier so you have more control over how the number works.
    • All this allows a more powerful perk system where almost every stats of a unit/ability/effect can be modified.
    • And finally the not so obvious one are the code. They are a lot more cleaner, efficient, easier to debug and maintain. It should make the framework more stable. It's easier too for further extension or customization.
     
    Last edited: Jan 22, 2019
  12. VFXROB

    VFXROB

    Joined:
    May 4, 2015
    Posts:
    27
    Thanks Song! Your a legend!
    That has fixed it, it was slightly modified to include the '' [ i ] "without it, it seemed to be calling to old prefabs. Seems like the Unity forum deletes this? when trying to add it, so you have have included it.
    if(unitList[ I ]==null || unitList[ I ].HP<=0) break;

    The new kit features sounds amazing!
    A few feature requests...
    Would you be able to add in an option to leave the bodies?

    Also a on status effects would be cool is to have status effects only effect certain unit types.
    Eg. 'an Archer type does less damage to a unit with the 'Shielded Perk' or an EMP grenade might stun a mechanical type but not effect an biological unit type.

    Thanks again for all your great work!
     
    Last edited: Jan 25, 2019
  13. VFXROB

    VFXROB

    Joined:
    May 4, 2015
    Posts:
    27
    GUIDE HOW TO LEAVE BODIES BEHIND
    Thought id put this together for others and myself as a reminder, and a big thanks to Song who did all the work. Be great if others could share any info like this!

    Firstly if you haven't done you will need to add in your own death clip in the unit animation.sc, that's a pretty general.

    Around line 1101 in unit.sc disable Destroy(thisObj);, by adding'//' //Destroy(thisObj); "this stops the body from disappearing."

    Around line 693 in unit.sc I added in below bold, without it the unit seems to be stuck on the moving animation, and does not transition with the death animation.

    if(HP<=0){
    //if the unit get destroyed there and then by overwatch
    float delay=1;
    if(unitAnim!=null) unitAnim.StopMove();

    StartCoroutine(Dead());
    if(!isAIUnit) TurnControl.SelectedUnitMoveDepleted();
    TurnControl.ActionCompleted(0.25f);
    yield break;

    If the game freezes on you when killing a unit in overwatch
    And line 69 of AIManager change to the below but remove the gaps between the [ i ]'s there are two if them, for some reason the Unity forum deletes that bit of code when pasting here.
    if(unitList[ I ]==null || unitList.HP[ I ]<=0) break;

    And that's it!
     
    Last edited: Jan 22, 2019
  14. Tarrasque

    Tarrasque

    Joined:
    Jan 5, 2015
    Posts:
    21
    "In that case, you will need to disable the apply-root-motion flag on the Animator component."

    Thanks songtan, this fixed the issue. :)
     
  15. Rajmahal

    Rajmahal

    Joined:
    Apr 20, 2011
    Posts:
    2,101
    Hi Songtan,

    Do the new changes in 2018.3 affect the gridpainter or is it just the prefab editor windows? I'm in the midst of a product launch so can't really update now and what you're saying has me worried. I can live without the prefab editor windows personally but really need the gridpainter to keep working well.
     
  16. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    Unity2018.3 only breaks the window editors that are used to edit prefab. This include the unit, collectible, ability, perk and damage-table. Other editor (including grid-painter) works just fine.

    Anyway, I've just made an update that should fix the problem with Unity2018.3. I have to make some drastic changes to how the data are stored (the DB objects in the 'Resources' folder). They are now being stored on scriptable-objects instead of prefabs. Upon update, you will notice the window-editor have a button that allow you to transfer the data from the prefabs based DB objects to the scriptable-object based DB object. So you won't be losing any changes you made. Since I want to get this fix out asap, I haven't got the opportunity to test things thoroughly. If you come across any issue, please let me know. Once again sorry for the inconvenience.
     
  17. VFXROB

    VFXROB

    Joined:
    May 4, 2015
    Posts:
    27
    Hey Song!

    Thought id give the new update a test run!

    The short version it seems to be broken, I first initially just updated my version, I'm only familiar with the unit editor and faction editor so far, but it seems to be also effecting perks, and not sure about other things.

    Here is what's happening to an existing project.



    Then I thought hey, its a new update of course stuff will be errors i'll download the a fresh new version from the asset store! but that also is equally broken.



    Please let me know if you need any more information, and thanks for your hard work!
     
  18. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    I've just done a quick test. Seems to be working fine. What I've noticed is the scriptable-objects can be a bit temperamental going through import and export process. The link to the script could be broken. Please check yours and see if that's the case. See the image for reference:

    New_TBTK_DB.png
    If the link on the object is indeed broken, you will have to manually reassign the scripts. You will find them in 'Scripts/DB'. Just make sure each scriptable-db-object has their corresponding script assigned.
     
    Last edited: Jan 23, 2019
  19. VFXROB

    VFXROB

    Joined:
    May 4, 2015
    Posts:
    27
    Hey Song, I downloaded another fresh test version and their were indeed some of those scripts not connected to the database. Still throwing a few errors. Ive got some screen grabs and a vid, hope this helps!

    When first downloading the Pack.
    image1 warnings.JPG

    After connecting the Scripts to the Database and clicking Play
    image2.JPG

    Also here is a vid.


    Just so you know the faction DB is showing up buggy in that video but seems to be connected and working ok with the fresh new download.
     
    Last edited: Jan 24, 2019
  20. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    Just uploaded another fix. I'm still not entirely sure about why the scriptable-object refuse to work sometime. I experiencing it a bit when I first trying to convert the old db on my end. But it has since been working fine for me. Anyway I've now added a method to create these scriptable db object. You can use the 'create' button on the ProjectTab to create new db. So if one of them breaks (like your FactionAbiliityDB), just delete the existing one and create a new one. Please make sure you place it in the right folder otherwise it won't work.
     
  21. VFXROB

    VFXROB

    Joined:
    May 4, 2015
    Posts:
    27
    Hey Song! You truly are a magician.

    It works perfectly, the update seems to have integrated seamlessly with my project from the old version, and also downloading a fresh new version has no errors. There didn't seem to be a need to connect scripts to databases.

    Again thankyou for your hard work.
     
  22. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    Good to know. :)

    There's no need to thank me. I should be thanking your for purchase and using TBTK.
     
  23. VFXROB

    VFXROB

    Joined:
    May 4, 2015
    Posts:
    27
    Hey Song just some questions when you have time. Just a question about Attack per turn and Counter Attack per Turn in the Unit Editor and wondering if they are working properly?

    I've set the Shield Infantry to Counter 3, and Attack to 3.

    For the Attack 3 times it seems to work fine for the Player but for the AI, after the initial first attack seems to ignore the min/max range of 0-1 and can attack at any target that isn't close. 1.09 in the video

    For the counter attack, that doesn't seem to be triggering at all, or maybe I'm not using it properly I've set the infantry to counter 3 times but doesn't seem to be triggering any events after the attack?

    Here is a vid!


    Also not sure if Hybrid unit is working, I set the archer regular attack to min/max 3-5 range, and turn on hybrid unit with the range of 1 but no option comes up to attack when moving next to an enemy.


    Hope this isn't annoying, I actually have been really enjoying using this, I've been watching your old videos and other tutorials/examples using your kit! Its pretty mind blowing! Most recently I'm pretty excited (among many other things) to come across the damage armour table! eg, Archer do less damaged to shielded infantry and Pikemen do more to cavalry!
     
  24. Capo_291

    Capo_291

    Joined:
    Jan 17, 2019
    Posts:
    12
    Thanks for your quick response. I was wondering how would I go about making the AI use an ability. Specifically a spawn in unit ability.
    I would just like to check for a certain AI unit then make that unit use a spawn in ability. I'm new at coding in unity and I can't seem to figure it out.
     
  25. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    @VFXROB, Have you check the 'Enable CounterAttack' option in GameControl. Without that, counter attack will not work. Also to clarify, hybrid-unit melee attack is just an add-on to normal attack where the unit will switch to melee if the target is in melee range. It won't work with min-attack-range. If you have a unit with min-attack-range that is larger than the melee range, the min-attack-range will override that. As for the AI that attacks beyond it's max-attack-range, I can't seem to replicate that. The code seems fine at a glance. Does it happen consistently. Do you notice anything that trigger this?

    I do however notice a bug about counter-attack, that is they ignore unit min-attack-range. You can fix that easily by adding this two lines of code in line1132 of Unit.cs, in the function CanCounter():
    Code (csharp):
    1. float minAttackRange=GetAttackRangeMin();
    2. if(minAttackRange>0 && dist<minAttackRange) return false;

    @Capo_291, You will need to look at AIManager.cs, specifically the function Analyse() and MoveUnitRoutine(). The former is an algorithm that search for a tile for the unit to move to and which is the best target to attack and the later act upon that information. So if you want your AI unit to use any ability, this is where to add them.
     
    Stexe likes this.
  26. VFXROB

    VFXROB

    Joined:
    May 4, 2015
    Posts:
    27
    Thanks Song! you were right I didn't have enable counter attack checked, and thanks for the info on the hybrid unit!

    Why the AI can attack distant targets after the initial attack is a weird one, especially as a player I can only attack units within melee range with the range 0-1, and each attack after that is the same.

    I have replicated the issue with the MK 1 Tanks,

    Set the unit to have a min/max range of 0-1, and allow the unit to attack 3 times per turn.

    The AI will always make the initial attack at close range as intended but any attacks per turn after that it always picks distant targets, up to 2-4 hex's away.

    Thanks again for your time, I've added that above code in!
     
  27. Tarrasque

    Tarrasque

    Joined:
    Jan 5, 2015
    Posts:
    21
    Hi Songtan, any idea what is giving these errors in new version?

    Not_working_new_tbtk.png
     
  28. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    @VFXROB, Found the problem. you can fix it by adding 'targetTile=unit.tile;' to line 185 in AIManager.cs

    @Tarrasque, Looks like the standard asset script I've included with the package is missing. Have you accidentally deleted it or you didn't import it in the first place?
     
  29. Tarrasque

    Tarrasque

    Joined:
    Jan 5, 2015
    Posts:
    21
    Ok, thanks. I don´t know but I`ll reimport..
     
  30. VFXROB

    VFXROB

    Joined:
    May 4, 2015
    Posts:
    27
    Thanks Song for your incredible work!

    That indeed did fix it!
     
  31. Capo_291

    Capo_291

    Joined:
    Jan 17, 2019
    Posts:
    12
    Thanks for your response.
    I was able to find the Analyse() and MoveUnitRoutine() functions. I can also see where I need to add the code in for AI to use abilities, but I don't know what function to use to call the ability.
    Second question
    I have been able to implement infantry in the game with animations and everything is working great, except one thing. When I tell a soldier to shoot at an enemy they turn the wrong way and are aiming in the wrong direction. I don't have this problem with vehicles just the infantry. I tried changing their Y rotation by 180 degrees but that didn't do the trick, I also tried tweeking the aiming settings in the unit editor in every way I could think of and can't seem to figure it out.
    Sorry for all the questions, I'll try to figure out as much as I can by myself, thanks again for the great asset.
     
  32. VFXROB

    VFXROB

    Joined:
    May 4, 2015
    Posts:
    27
    Hey Capo, i am also curious about this.

    In the support doc, under How things work then Unit Prefabs the doc it says
    "It's recommended that any mesh is place as the child transform of the unit prefab. When placing the mesh, make sure it's facing the +ve z-axis when the unit rotation is at (0, 0, 0) otherwise the unit may not be facing the correct way in runtime."

    I hope this helps, check your infantry model are facing the same way as your tank or the kit tanks.

    There doesn't seem to be a button that resets the transformation like the 3d app Maya.

    But you can try this from the below article
    "One thing you can do is make your Object child of new GameObject. Through which your child's Objects position would become 0,0,0. Parent object's position would be something else"
    https://answers.unity.com/questions/1405550/is-it-possible-to-reset-the-position-values-of-an.html
     
  33. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    @Capo_291, The code to activate an ability on a unit is ActivateAbility() on the unit instance (in Unit.cs). You will need to pass the target tile and the index of the ability in the unit's ability list. The target tile of course, being where the ability 'hits'. In your case, you will probably want an empty tile close to the unit. Try unit.tile.GetNeighbourList(true), that should give you a list of the unit's empty neighbouring tile.

    Regarding the infantry aiming direction, it's like what @VFXROB said. If you are really struggling, send me the prefab in question if you don't mind. I'll see if I can tweak it for you.


    @VFXROB, Thanks for trying to help. :)
     
  34. Tarrasque

    Tarrasque

    Joined:
    Jan 5, 2015
    Posts:
    21
    @songtan or anyone else..

    I`m creating a game where there are random encounters with different creatures on different "arenas" or backgrounds like forest, desert etc. So it is needed to have different scenes with different obstacles and also different enemy units with the type and number of encountered creature chosen outside of TBTK. I have read through the forums and there are pieces of advice here and there how to do certain things. However, documentation and videos show pretty much how things are done in editor, so I was thinking that if someone would be able to give simple step-by-step instructions on how to generate grid and units in runtime. I will probably be able to figure out these things also myself, but having this kind of short instruction would be really helpful for me and probably also for other newbies.

    Also at the moment there is this kind of issue that I Guess the scriptable objects are working for under the folder TBTK-> resources->db_TBKT->UnitDB
    But If when I tried in scripts -> DB folder and create a unitDB and add prefab to it, it wont work.
    So Its working fine with in resources folder, but when I manually create a unitDB then it will not show the unit I attached to it.
     
    Last edited: Feb 1, 2019
  35. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
  36. Tarrasque

    Tarrasque

    Joined:
    Jan 5, 2015
    Posts:
    21
    Ok, thanks songtan. I try to ask only specific questions.

    And folder should be correct, but still having a problem while I am trying to add the scriptable objects in the TBTK project. After creating the UnitDB in the right folder I've add the prefab of unit, but it isn't showing up at the runtime?
     
  37. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    Not showing up in runtime? Or not showing up in the editors?

    To clarify, having unit in the db only gets it to show up in the editors. In UnitEditor so you can edit it, In PerkEditor so it can be made a target for perk, in GridEditor so you can place it on the grid, etc.

    To get the unit to show up in runtime however, you need to either set it as a starting unit (or spawn unit) of a particular faction in the game, or deploy the unit on the grid before the game start (using GridEditor).
     
  38. Capo_291

    Capo_291

    Joined:
    Jan 17, 2019
    Posts:
    12
    Thanks for your previous answers.
    I was able to use unit.ActivateAbility(targetTile, 1); to make units use there second ability on the targeted tile. However I was unable to use unit.tile.GetNeighbourList(true), without getting errors. I'm not sure how to set it up properly, also the AI will cast the ability whether or not the troop has sufficient Action Points, they just kept using it until they were in the negatives. I'm going to keep testing it out and see if I can get better results, if you have any advice for me when it comes to getting AI to use abilities I would appreciate it greatly. Or if there is a guide or forum topic on it that would be great too.
    Thanks for all of your help.
     
  39. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    What is the error you get when you call unit.tile.GetNeighbourList(true)?

    For the problem with ActionPoints, you can simply do a check if the unit has sufficient ap point before calling unit.ActivateAbility(targetTile, 1);. Or you can simply call unit.abilityList[1].IsAvailable() to check if that ability is valid. That function would check all the condition required like ap, cooldown, etc..
     
  40. Capo_291

    Capo_291

    Joined:
    Jan 17, 2019
    Posts:
    12
    Okay thanks I'll try that.
    It says that it has an invalid argument. How do I pass a tile from the list that is generated by unit.tile.GetNeighbourList(true).
     
  41. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    GetNeighbourList() return a list of tile. Try choose one randomly from the list. Like this:
    Code (csharp):
    1.  
    2. List<Tile> tileList=unit.tile.GetNeighbourList(true)
    3. unit.ActivateAbility(tileList[Random.Range(0, tileList.Count], 1);
    4.  
     
  42. OrionDesaul

    OrionDesaul

    Joined:
    Feb 23, 2018
    Posts:
    10
    Good morning/evening,
    I'm having trouble with getting non-tbtk associated objects reacting to "mouse over" or "mouse down" events, can you point me in the direction of the script that handles these?
     
  43. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    There are two type of mouse over event I'm using for TBTK. One for grid and one for the UI elements. The one for grid simply use a simple raycast (check GetTileOnCursor() in GridManager). The one for UI works on for UI elements. It's a script that get attached to the UI element that respond to mouse over event. The code is in UIClass.cs. The mono behaviour class is called UIItemCallback, which you can see is attached to the root-object of UIObject when the method SetCallback() of the UIOBject is called.
     
  44. OrionDesaul

    OrionDesaul

    Joined:
    Feb 23, 2018
    Posts:
    10
    Can you think of a reason that Tbtk might Block mouse interactions with objects it doesn't recognize?
     
  45. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    There are many reasons, and it depends on the object. Is it an in game object, or an UI element. If the former, does it has a collider? Then does it has the the correct layer (the raycast is set to only detect a specific layer)? If the later, Is the canvas is being set to interactable and so on.

    The thing is without knowing the details specifically, it's very hard to say. Why don't you tell me what exactly are you trying to do and how are you doing it.

    I should say that starting Monday morning, I'm going to be travelling for a few days so please forgive me for slower respond time. I hope you understand.
     
  46. Capo_291

    Capo_291

    Joined:
    Jan 17, 2019
    Posts:
    12
    Thanks for your help Songtan. I've been able to make some progress. How can would I be able to check the unit ID or type when the AI manage is cycling through the different AI units. I want certain units to call different abilities and some not to use any at all so how do I check which unit is being moved or that is attacking?
     
  47. Capo_291

    Capo_291

    Joined:
    Jan 17, 2019
    Posts:
    12
    Also when I use unit.abilityList[1].IsAvailable() it doesn't seem to keep units from using their abilities and they still go into the negative with their AP.

    List<Tile> neighbourList = unit.tile.GetNeighbourList();
    for (int i = 0; i < neighbourList.Count; i++)
    {

    if (neighbourList.Count > 0)
    {
    unit.abilityList[0].IsAvailable();
    unit.ActivateAbility(neighbourList[Random.Range(0, neighbourList.Count)], 0);
    }
    }

    I wrote this and the AI just keeps using the ability even if they run out of AP.

    Sorry about all the questions I've been studying the coding aspect of Unity and C# for a while and just having trouble wrapping my head around a few things. Thanks again for all of your help.
     
  48. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    IsAvailable() is a condition check. You are suppose to use it with if statement. Only call ActivateAbility() when IsAvailable() returns true. Also, I'm not sure if this is your intention, based on the code you have shown, you are using the ability as many time as the number of empty neighbouring-tile the unit has.

    I'm not sure how to answer your question regarding check which unit is which. There are many ways to do it. And depends on why are you checking it and how you intend to use the result, you may want to use one way or another. For instance, if you want to identify a type of unit, you can simply check the unit prefab. If it's a particular unit in a particular scene, you may want to create a unique variable just for that.

    Forgive me for being honest, but I think trying to tackle TBTK's AI might be beyond what your coding skill. I would strongly recommend you to get a better understanding of basic coding principal before proceeding.
     
  49. Tarrasque

    Tarrasque

    Joined:
    Jan 5, 2015
    Posts:
    21
    I have been planning that one randomly selected edge square would be an exit-tile i.e. player could flee the battle by walking into that tile. Any hints how would be the best way to do this? So like first place that "exit" text into one randomly selected edge square and then end the combat if player walks into that tile. I was thinking of maybe making that as collectable, but I guess those are placed randomly into any square also in the middle of the grid. Also fleeing would be third ending condition as it is not actually either win or lose condition.
     
  50. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    The easiest way is to assign the tile or tiles in question in GameControl as the game ending tile. Then in the unit MoveRoutine(), check with GameControl to see if the player unit has ended on any of the tile specified. If yes, end the game (by calling GameControl.GameOver());

    Strictly speaking, there is no win or lose state. It's just a matter of the UI displaying player won or lost based on what faction is left in the game. That can easily be changed. So you can easily modify it to display something else based on what you pass to GameControl.GameOver().

    Hope this make sense.