Search Unity

Fantasy AI 2.0 [RELEASED]

Discussion in 'Assets and Asset Store' started by brilliantgames, Mar 1, 2012.

  1. primus88

    primus88

    Joined:
    May 14, 2013
    Posts:
    611
    Indeed I still have this problem on ocasions. Needles to say, for a strategy game where each unit counts, having this problem is a game breaking bug.
     
  2. agent_Macgyver

    agent_Macgyver

    Joined:
    Sep 1, 2012
    Posts:
    36
    Hi Primus88,

    I think I figured it out. try replacing the entire AIDestroy script with this:

    Code (csharp):
    1. public class AIDestroy : MonoBehaviour {
    2.     public bool destroyai;
    3.    
    4.     // Use this for initialization
    5.     void Start () {
    6.    
    7.     }
    8.    
    9.     // Update is called once per frame
    10.     void Update () {
    11.        
    12.     if(destroyai){
    13.         AI ai=(AI)GetComponent("AI");
    14.             if(ai){
    15.                
    16.                 //Clear from FRIENDLIES list
    17.                 if(ai.friendly.Count>0){
    18.                 int flist=ai.friendly.Count;
    19.                     for (int f = 0; f < flist; f++){
    20.                                 AI aif=(AI)ai.friendly[f].GetComponent("AI");
    21.                                     if(aif){
    22.                                         aif.friendly.Remove(transform);
    23.                                     }
    24.                     }
    25.                    
    26.                 }              
    27.  
    28.                
    29.                 //clear from ENEMIES list
    30.                 if(ai.enemys.Count>0){
    31.                 int elist=ai.enemys.Count;
    32.                     for (int i = 0; i < elist; i++){
    33.                                 AI aie=(AI)ai.enemys[i].GetComponent("AI");
    34.                                     if(aie){
    35.                                         if(aie.enemy==transform){
    36.                                                 if(aie.attack){
    37.                                                     aie.attack=false;
    38.                                                     if(aie.targetlocateto)aie.gototarget=true;
    39.                                                     else aie.idle=true;
    40.                                                 }
    41.                                             }
    42.                                         aie.enemys.Remove(transform);
    43.                                     }
    44.                     }
    45.                    
    46.                 }
    47.                
    48.                 //delete the object - the unitlist is not cleared for all other AIs, because I am concerned about messign with it. You can clear it with on the AI script ai.unitlist.Clear();
    49.                 Destroy(gameObject);
    50.             }
    51.                
    52.         }
    53.        
    54.     }
    55. }
    I changed up the friendly code, this will probably cause a problem if you have companions enabled or something, but rough and cut this should work!
     
  3. primus88

    primus88

    Joined:
    May 14, 2013
    Posts:
    611
    Thank you Mac for posting this. I tried it and though indeed I think it reduced the errors, they are still occuring though.
    And is it possible that it can slow down my game if I have many units dying and spawning ? I observed the game started to slow down a bit to the end of the battle.

    Here is the error :
    MissingReferenceException: The object of type 'Transform' 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.
    UnityEngine.Component.get_gameObject () (at C:/BuildAgent/work/7535de4ca26c26ac/Runtime/ExportGenerated/Editor/UnityEngineComponent.cs:170)
    UnityEngine.Component.GetComponent (System.String type) (at C:/BuildAgent/work/7535de4ca26c26ac/Runtime/ExportGenerated/Editor/UnityEngineComponent.cs:197)
    AI.Update () (at Assets/MyScripts/AI.cs:679)

    Pointing to :

    health choose=(health)enemys[ce].GetComponent("health"); //from the AI.cs
     
  4. agent_Macgyver

    agent_Macgyver

    Joined:
    Sep 1, 2012
    Posts:
    36
    I do not have that error. Perhaps you are calling the AIDestroy script at the wrong time?

    I have the line:

    GetComponent<AIDestroy>().destroyai=true;

    right after the line:

    if(hpres){
     
  5. agent_Macgyver

    agent_Macgyver

    Joined:
    Sep 1, 2012
    Posts:
    36
    I do not have that error. Perhaps you are calling the AIDestroy script at the wrong time?

    I have the line:

    GetComponent<AIDestroy>().destroyai=true;

    right after the line:

    if(hpres){
     
  6. primus88

    primus88

    Joined:
    May 14, 2013
    Posts:
    611
    I have the piece of code you said in AI.CS but it is commented anyway from the beginning because it is for re-spawn.

    So I am in the position I can't go on with development because of this game breaking bug...
    Can you please send me through mail the AI.cs , AIdestroy.cs scrips and the piece of code yo use to destroy ?
    At least then we will both be in the same situation..
     
    Last edited: Aug 9, 2013
  7. Seith

    Seith

    Joined:
    Nov 3, 2012
    Posts:
    755
    Hello, I know the question was already asked several months ago but I was wondering if there are any progress on adding Mecanim support...? Thanks.
     
  8. im

    im

    Joined:
    Jan 17, 2013
    Posts:
    1,408
    hi just got latest paid version of this asset and am using it with latest unity 4.2 indie (free) and when I download and import it into a new project and open the scene "Protect The Crystal(newmesh)" i get 45 errors, and 10 warnings which i ignore!

    just in case i downloaded and imported it twice so its not the asset being download its got to be missing in the one uploaded.

    bunch of

    and bunch of

    and bunch of

    and hundreds of warnings like


    if then i try running it i get 9 errors!

    bunch of

    and

     
    Last edited: Aug 28, 2013
  9. 99thmonkey

    99thmonkey

    Joined:
    Aug 10, 2012
    Posts:
    525
    For all of those Animation Bip001 errors, click the error and follow it to the character. They need to reference player instead of Bip001 (I think that's what it was).

    Those sword errors, I couldn't figure out, so I just deleted the swords. They were part of the minicrystal project which I'm not using.

    For the Terrain ones, I ended up following that and deleting the terrains under the Tree Editor folder. After that no more errors.

    Only problem I'm at is if I run some Fantasy AI in the Dynamic Navigation demo scene, the AI tends to get stuck at the top of the stairs. It's probably just a setting, but *shrugs*
     
  10. brilliantgames

    brilliantgames

    Joined:
    Jan 7, 2012
    Posts:
    1,937
    The terrain errors are nothing to worry about. It was a small error that occurred during the exporting of the package. The error in the swords, happened for some reason when Unity 4.0 came along. I believe it was a command I used that is no obsolete. Either way none of these errors affect any of the AI scripts themselves.

    The AI get stuck at the top of the stairs? Are they spinning around? Or is their path failing?
     
  11. im

    im

    Joined:
    Jan 17, 2013
    Posts:
    1,408
    so are you going to fix any of these errors or are you going to continue to ignore them. the demo scene that ships with the asset won't even run, starts throwing exceptions from the instant that you load it. you just did a release, unity 4 came out quite a long time ago, you appear to understand what is causing the errors and the errors are still there, so fix the errors and include the numerous demo scenes that you show in the videos and snapshots, but do not include with the asset.
     
    Last edited: Aug 30, 2013
  12. primus88

    primus88

    Joined:
    May 14, 2013
    Posts:
    611
    This is the last time I try to mend the situation.
    I still have the errors when spawning units. The AI breaks completely for my units and since in my game every unit counts, this breaks the game.

    Brilliant games, I really need your help with this. I'm willing even to pay, just to see this fixed. Otherwise I will rate this pack proportional to the amount of problems and wasted time I spent on it trying to fix it.

    Thanks
     
  13. Sherasoft

    Sherasoft

    Joined:
    Nov 17, 2013
    Posts:
    8
    I have a maze of cubes and a cube floor.. all have box collider but your fantasy AI characters seems to know how to pass through walls! what's going on? I even tried to tag all the wall cubes as obstacles but with no difference!
     
    Last edited: Dec 18, 2013
  14. CommunityUS

    CommunityUS

    Joined:
    Sep 2, 2011
    Posts:
    240
    Hi gang. Love the new price and just rated 5 stars. Any chance you plan on creating a private guthub or something. I'd love to continue growing this asset and fixing the above mentioned bugs for you together with a community. Fantastic base...especially with the UMA asset coming out. The indie playing field just got leveled!
     
  15. Lohs

    Lohs

    Joined:
    Dec 15, 2013
    Posts:
    1
    hi brilliant,
    do you know a problem is why the player will pass through with my building? i have set collider but useless.
     
    Last edited: Jan 6, 2014
  16. technotdc

    technotdc

    Joined:
    Oct 21, 2011
    Posts:
    60
    Hi........

    Someone has fixed the the aidestroy script ?????????

    I have this error:
    The object of type 'Transform' 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.



    Thanks
     
  17. CommunityUS

    CommunityUS

    Joined:
    Sep 2, 2011
    Posts:
    240
    I had to delete some stuff attached to the heads and joints. Then that error went away. What highlights in the hierarchy when you click the error?
     
  18. technotdc

    technotdc

    Joined:
    Oct 21, 2011
    Posts:
    60
    Thanks ¡¡¡¡¡
     
  19. GayanJayasundara

    GayanJayasundara

    Joined:
    Jan 18, 2014
    Posts:
    8
    Hi


    I have 2 problem with customizing Protect The Crystal

    1. When i press Space bar for jump player go to sky ?

    2. Cross Player and AI when fighting them closely

    $Crystal Screen.jpg

    How can i solve this.

    Thanks
     
    Last edited: Feb 23, 2014
  20. GayanJayasundara

    GayanJayasundara

    Joined:
    Jan 18, 2014
    Posts:
    8
    Did you upload new update? where is the download link?
     
  21. brilliantgames

    brilliantgames

    Joined:
    Jan 7, 2012
    Posts:
    1,937
    Hello everyone. I know its rare I make an appearance here, but I wanted to show you something.

    I have released version 2 of the game Soul Tyrant. It uses Fantasy AI in combination with Dynamic Navigation. During the design of this game, I really continued to see how useful Fantasy AI and Dynamic Navigation are to me. If it wasnt for combination of these 2 systems, this game wouldn't have been possible to do in the amount of time it took.

    Please, if you support Fantasy AI, look into purchasing Dynamic Navigation. Its one of the most powerful pathfinding systems and compatible with Fantasy right out of the box.

    Asset Store link: https://www.assetstore.unity3d.com/#/content/5482

    Play Soul Tyrant free @ http://www.martiangames.com/index.php?params=game/478/Soul-Tyrant-V2/

     
  22. rickcollette

    rickcollette

    Joined:
    Mar 17, 2013
    Posts:
    304
    I am having fits with the animation.
    I tested a couple of models from the asset store, and just cannot seem to get anything other than the spartan king to work right.
    For this test, I am using the Dark Knight model ( https://www.assetstore.unity3d.com/#/content/4624 )

    I took the existing "Player" rigged prefab and removed the spartan king from it, adding in the Dark Knight, then changed the anime to point to the right ones.
    I can get him to move, but the anime don't play... this is true for several of the models I am using.

    Any ideas?
    $Screen Shot 2014-03-04 at 7.43.27 AM.png
     
  23. technotdc

    technotdc

    Joined:
    Oct 21, 2011
    Posts:
    60

    Something is wrong........because I use other models without any problem
     
  24. rickcollette

    rickcollette

    Joined:
    Mar 17, 2013
    Posts:
    304
    well.. yeah something is wrong ;) Its why I posted the question.
     
  25. KrisSchnee

    KrisSchnee

    Joined:
    Mar 9, 2014
    Posts:
    15
    Can you please clarify the license for the "Advanced Fantasy AI Pack 2.0"? It looks like it's free and includes both the AI and the assets for the "Protect the Crystal" game.
     
  26. Venged

    Venged

    Joined:
    Oct 24, 2010
    Posts:
    500
    Since this became free it may not have been updated for the latest version of Unity.
     
  27. Nostre

    Nostre

    Joined:
    Mar 3, 2012
    Posts:
    44
    Occlusion Culling was the way to not render the entire object not in use in game, since this has been removed in Unity 4.3 Fantasy AI give a lot of error.

    Removing the object is not the way to not render what we don’t use, what will it be?
     
  28. AlexIsmere

    AlexIsmere

    Joined:
    Jun 1, 2014
    Posts:
    5
    Very Usefull, I like this!!
     
  29. Infiniteno

    Infiniteno

    Joined:
    May 11, 2014
    Posts:
    11
    Did you get this fixed? I can get only one animation to play and only if I loop it. Otherwise one animation on a model will play once and stop. I have tried over 10 models with the same issue. Im using Maya 2015 so maybe that's the issue? Or perhaps the lack of an update for this package?
     
  30. Infiniteno

    Infiniteno

    Joined:
    May 11, 2014
    Posts:
    11
    Have you put the rig to Legacy? Have you duplicated the original prefab and then after setting it up in your scene hit apply so the prefab is the same thing? This fixed it for me.
     
  31. Frogger007

    Frogger007

    Joined:
    Jun 24, 2014
    Posts:
    338
    After i had imported the AI i have try to start the 'protect the crystal' demo.

    I get allways the following errors:

    8 time:
    MissingComponentException: There is no 'Renderer' attached to the "SwordGeneric" game object, but a script is trying to access it.
    You probably need to add a Renderer to the game object "SwordGeneric". Or your script needs to check if the component is attached before using it.
    CharacterDistanceCulling.Update () (at Assets/Advanced Fantasy AI Pack V2.0/Scripts/AI/CharacterDistanceCulling.cs:27)

    1 time:
    MissingComponentException: There is no 'Renderer' attached to the "Lamp(hi)" game object, but a script is trying to access it.
    You probably need to add a Renderer to the game object "Lamp(hi)". Or your script needs to check if the component is attached before using it.
    CharacterDistanceCulling.Update () (at Assets/Advanced Fantasy AI Pack V2.0/Scripts/AI/CharacterDistanceCulling.cs:44)

    I use Unity3D Free 4.5.1f3.
     
  32. unity3dcoder

    unity3dcoder

    Joined:
    Apr 15, 2013
    Posts:
    8
    During melee combat (and probably ranged too) I want to perform randomized damage amounts between upper/lower limits - something akin to rolling a die plus modifiers in AD&D. How would I achieve this ? If you can, please provide code examples as I am not a competent coder.

    Thanks.
    (Unity 4.5.2f1)
     
  33. colpolstudios

    colpolstudios

    Joined:
    Nov 2, 2011
    Posts:
    150
    Hi, i am curious has the developer of this asset given up on updating or fixing the errors reported within the threads?

    Both versions are FREE.

    The wiki page does not seem to exist.

    The unity asset store needs to be informed if the developer no longer gives help in relation to the asset.

    As I have only just found the thread and both assets are now free, I feel I must give the developer time to respond to the questions posed within the thread.
     
  34. hopeful

    hopeful

    Joined:
    Nov 20, 2013
    Posts:
    5,686
    (The developer has indeed moved on. This is an old project that has become a free code source for those learning to make their own projects in Unity.)
     
  35. agent_Macgyver

    agent_Macgyver

    Joined:
    Sep 1, 2012
    Posts:
    36
    Hi everyone, I made another attempt at the AIDestroy Script, and I have not had any errors yet. What I think was happening was that the dying AI calls out to all other AIs and asks to clear it's reference from their lists. BUT - if the AI it is calling out to is already gone, it errors out. What this does is before it makes the call, it asks if the AI still exists - if the AI doesn't exist, it skips it and moves on.

    Code (CSharp):
    1. using UnityEngine;
    2. using System.Collections;
    3. using System.Collections.Generic;
    4.  
    5. public class AIDestroy : MonoBehaviour {
    6.     public bool destroyai;
    7.  
    8.     // Use this for initialization
    9.     void Start () {
    10.  
    11.     }
    12.  
    13.     // Update is called once per frame
    14.     void Update () {
    15.      
    16.     if(destroyai){
    17.         AI ai=(AI)GetComponent("AI");
    18.             if(ai){
    19.             ai.enabled = false;
    20.             int flist=ai.friendly.Count;
    21.                 if(ai.friendly.Count>0){
    22.         for (int f = 0; f < flist; f++){
    23.                         if (GetComponent<AI>().friendly[f]){
    24.                     AI aif=(AI)ai.friendly[f].GetComponent("AI");
    25.                         if(aif){
    26.                     if(aif.companionleader=null){
    27.                         aif.companionleader=null;
    28.                         aif.companion=false;
    29.                         aif.targetlocateto=null;
    30.                         aif.gototarget=false;
    31.                         aif.gototargetnostop=false;
    32.                         aif.idle=true;
    33.                     }
    34.                     }
    35.                     }
    36.                     }
    37.                 }
    38.              
    39.                 if(ai.enemys.Count>0){
    40.                 int elist=ai.enemys.Count;
    41.         for (int i = 0; i < elist; i++){
    42.                     if (GetComponent<AI>().enemys[i]){
    43.                     AI aie=(AI)ai.enemys[i].GetComponent("AI");
    44.                         if(aie){
    45.                 if(aie.enemy==transform){
    46.                         aie.enemy=null;
    47.                         if(aie.attack){
    48.                             aie.attack=false;
    49.                             if(aie.targetlocateto)aie.gototarget=true;
    50.                             else aie.idle=true;
    51.                         }
    52.                     }
    53.                 aie.enemys.Remove(transform);
    54.                     }
    55.                     }
    56.                     }
    57.                  
    58.             }
    59.                 Destroy(gameObject);
    60.         }
    61.              
    62.             }
    63.      
    64.     }
    65. }
    66.  
    Please let me know if this works, or does not work for you. I am not a brilliant coder, so I don't think i can fix it further, but if you have suggestions I want to hear them!

    EDIT: I made a small update on May 25th, 2015.
     
    Last edited: May 25, 2015
    MahaGaming likes this.
  36. Pollawat

    Pollawat

    Joined:
    Aug 27, 2016
    Posts:
    192
    Please help me.

    I followed every step from a tutorial but not work for me. Here I recorded a video for somebody maybe this can help.



    And here is the code.

    MissingComponentException: There is no 'Animation' attached to the "Paladin_w_Prop_J_Nordstrom" game object, but a script is trying to access it.

    You probably need to add a Animation to the game object "Paladin_w_Prop_J_Nordstrom". Or your script needs to check if the component is attached before using it.
    UnityEngine.Animation.get_Item (System.String name) (at C:/buildslave/unity/build/artifacts/generated/common/modules/Animation/AnimationsBindings.gen.cs:404)
    AI.Update () (at Assets/Fantasy AI 2.0/Scripts/AI/AI.cs:1146)


    =====================================================================================

    I try to use another character, Animation type, Different Type of character but the result is the same.

    Thank you.

    ps. sorry for my bad English.