Search Unity

  1. Unity 2019.2 is now released.
    Dismiss Notice

[RELEASED] Emerald AI 2.3 - The Ultimate Universal AAA Quality AI Solution

Discussion in 'Assets and Asset Store' started by BHS, Jun 26, 2015.

  1. gearedgeek

    gearedgeek

    Joined:
    Jun 19, 2015
    Posts:
    125
    Has anyone used Emerald AI with Core GameKit?
     
  2. magique

    magique

    Joined:
    May 2, 2014
    Posts:
    3,632
    Yes, I use it with Core GameKit. You are probably concerned with pooling issues. I've personally had to add some additional code in order to make it work smoothly. The main thing was to create a new class that had references to all the Emerald classes like EmeraldAISystem, EmeraldAIInitializer, etc, and I have them disabled in the prefab. Then in an OnSpawned() function I enable them. I might have had to do some other things, but I don't remember all the details. But if you have a specific problem I'm sure I could help you find a way to make it work.
     
  3. gearedgeek

    gearedgeek

    Joined:
    Jun 19, 2015
    Posts:
    125
  4. magique

    magique

    Joined:
    May 2, 2014
    Posts:
    3,632
    I saw that post, but I admit that I don't quite understand what you're saying. In your post, you state the following:

    "I'm using Core GameKit to spawn groups of enemies in the scene. But all the AI will move to one location instead of the spawner location"

    Do you mean that the AI are not spawning in their defined spawn positions? What do you mean by moving to one location? What location? Are the AI supposed to spawn in random positions and then wander? More details would help.
     
  5. gearedgeek

    gearedgeek

    Joined:
    Jun 19, 2015
    Posts:
    125
  6. magique

    magique

    Joined:
    May 2, 2014
    Posts:
    3,632
  7. gearedgeek

    gearedgeek

    Joined:
    Jun 19, 2015
    Posts:
    125
    If you start killing AI from Spawn B they will start moving.
     
  8. magique

    magique

    Joined:
    May 2, 2014
    Posts:
    3,632
    OK. I had killed some from spawn A and nothing unusual happened. I will try going to spawn b.
     
  9. magique

    magique

    Joined:
    May 2, 2014
    Posts:
    3,632
    OK, so a couple of things. If I walk toward the spawn B AI without the sword up until they notice me and then turn around and go back for the sword, then those AI start moving toward spawn point B If they notice me again (line of sight method?) then they will stop moving toward A and head for me. However, if I get the sword and go attack them then I just fight them all and they never go to A.

    Is there any chance that your spawn point has a layer that the enemy might be detecting? Or that the AI are detecting each other's layers? I don't see how this is a Core Gamekit issue.
     
    Last edited: Jun 21, 2019
  10. gearedgeek

    gearedgeek

    Joined:
    Jun 19, 2015
    Posts:
    125
    I checked the layers for the LevelWaveSettings prefab in the scene and everything is set to Default. I'm using the demo AI from Emerald AI; the Forest Golem and Fallen Guardian.
     
  11. magique

    magique

    Joined:
    May 2, 2014
    Posts:
    3,632
    Not the prefab, but the actual spawn points in the scene. Also, I can't check the forest golem and fallen guardian details so you'll need to check the detection layers and see what they are detecting. Also, might want to check their factions as well.
     
  12. gearedgeek

    gearedgeek

    Joined:
    Jun 19, 2015
    Posts:
    125
    The AI is detection Character and the layers of the spawners are default.
     

    Attached Files:

    • 1.PNG
      1.PNG
      File size:
      25.1 KB
      Views:
      158
    • 2.PNG
      2.PNG
      File size:
      264.3 KB
      Views:
      160
    • 3.PNG
      3.PNG
      File size:
      31.4 KB
      Views:
      159
  13. magique

    magique

    Joined:
    May 2, 2014
    Posts:
    3,632
    OK, so it seems like it's all OK. I am no longer home so I can't help at the moment. What happens if you move spawn point A somewhere else? Does it still go to the new location? And if you turn off Spawn Point A completely, does it still go to where it was?
     
  14. gearedgeek

    gearedgeek

    Joined:
    Jun 19, 2015
    Posts:
    125
    @magique I have tried moving the spawners to a different location and clear the AI to respawn but they are still going to the same location. I think it's something in the code.
     
  15. magique

    magique

    Joined:
    May 2, 2014
    Posts:
    3,632
    OK, so the AI go to the position where Spawn Point A used to be even though it's not there anymore? If so, then there is definitely something odd going on and not related to Core GameKit for sure.
     
  16. BHS

    BHS

    Joined:
    Dec 21, 2009
    Posts:
    4,001
    ZGoodwin likes this.
  17. BHS

    BHS

    Joined:
    Dec 21, 2009
    Posts:
    4,001
    You will need a reference to the object you would like to interact with. Once you have this, you would call:
    Code (CSharp):
    1. YourObjectReference.GetComponent<EmeraldAI.EmeraldAISystem>().CurrentHealth
    There are also quite a few included example scripts that should give you a good idea on how to create custom scripts that alter an AI's variables.
     
  18. BHS

    BHS

    Joined:
    Dec 21, 2009
    Posts:
    4,001
    What wander type are you using? If you are using destination, and your AI are prefabs, they will all move to the same destination that was set by the prefab. If you aren't using it, I would recommend using the Stationary destination type. This allows the AI to stay stationary where they're spawned and will only move if a target gets within distance. Another option is the dynamic wader type. This allows AI to generate their own waypoints based on their current location.
     
    ZGoodwin likes this.
  19. BHS

    BHS

    Joined:
    Dec 21, 2009
    Posts:
    4,001
    What wander type are you using?
     
  20. BHS

    BHS

    Joined:
    Dec 21, 2009
    Posts:
    4,001
    Strange, I'm not sure. I haven't encountered this yet, but I will look into this to see if I can recreate it.
     
  21. BHS

    BHS

    Joined:
    Dec 21, 2009
    Posts:
    4,001
    No ETA yet, but I'm hoping to have it released as soon as possible.
     
    ZGoodwin likes this.
  22. BHS

    BHS

    Joined:
    Dec 21, 2009
    Posts:
    4,001
    Strange, even if the AI is in front of the player, it should flee in the opposite direction. I will look into this and fix it with the next update if there's an issue.

    You can damage an AI with something like this:
    Code (CSharp):
    1. void OnCollisionEnter(Collision C)
    2.         {
    3.             if (C.gameObject.tag == YourEmeraldAITag)
    4.             {
    5.                 if (C.gameObject.GetComponent<EmeraldAISystem>() != null)
    6.                 {
    7.                     C.gameObject.GetComponent<EmeraldAISystem>().Damage(YourDamageAmount, EmeraldAISystem.TargetType.Player, YourPlayerTransform, YourRagdollPushAmount);
    8.                 }
    9.             }
    10.         }
    As for fleeing from a projectile, you could do something similar and have the AI flee from the projectile using a trigger collider:
    Code (CSharp):
    1. void OnTriggerEnter(Collider C)
    2.         {
    3.             if (C.gameObject.tag == YourEmeraldAITag)
    4.             {
    5.                 if (C.gameObject.GetComponent<EmeraldAISystem>() != null)
    6.                 {
    7.                     C.gameObject.GetComponent<EmeraldAISystem>().Damage(YourDamageAmount, EmeraldAISystem.TargetType.NonAITarget, transform, 0);
    8.                 }
    9.             }
    10.         }
     
    ZGoodwin likes this.
  23. BHS

    BHS

    Joined:
    Dec 21, 2009
    Posts:
    4,001
    I have plans to add networking support and Mirror is one of the asset I plan to integrate, but it will be a couple of months.
     
    ZGoodwin and K4rha like this.
  24. Deckard_89

    Deckard_89

    Joined:
    Feb 4, 2016
    Posts:
    202
    @BHS In a future update could we get an option for the AI to stop chasing when the player has left their line of sight for a set period of time? Currently (as far as I know) we can only get them to stop chasing when the player exceeds the chase distance, which is obviously limiting for game scenarios set in small or indoors environments. The only way around it is by manually altering the AI state or clearing targets e.g. on entering a trigger, which is obviously not ideal.
     
    Last edited: Jun 23, 2019
  25. julianr

    julianr

    Joined:
    Jun 5, 2014
    Posts:
    1,110
    Hi @BHS is there built in functionality for the AI to detect what object they are colliding with, and do an action? For example, walk into a door trigger, then AI runs an event/animation etc to open it. Or collides with a small wall, and can climb over it. I've not used the current release yet, waiting for 2.3 :)
     
  26. tahir_ali

    tahir_ali

    Joined:
    Jan 6, 2018
    Posts:
    32
    How can i achieve ragdoll like in video. Plz help
     
  27. huntersteeger

    huntersteeger

    Joined:
    Dec 27, 2017
    Posts:
    17
    Create a ragdoll on your character with the ragdoll wizard then in the combat tab under the combat settings there will be a dropdown that says either ragdoll or animation. Choose ragdoll.
     
    tahir_ali likes this.
  28. o0neza0o

    o0neza0o

    Joined:
    Sep 6, 2015
    Posts:
    164
    Does emerald AI support creatures that are water/land creatures?
     
  29. adifrank

    adifrank

    Joined:
    Dec 11, 2017
    Posts:
    3
    I am using waypoint as wander type. And I tried it with both humanoid and non humanoid rid. Its the same. Do I waypoints have some kind of radius?
     
  30. o0neza0o

    o0neza0o

    Joined:
    Sep 6, 2015
    Posts:
    164
    Also, some of my AI move on my terrain but some of them do nothing, then when i have it in playmode and move them, they literally go back to their spot for some reason?
     
  31. BHS

    BHS

    Joined:
    Dec 21, 2009
    Posts:
    4,001
    That's a great idea. I will try to add this feature as soon as possible.
     
    ZGoodwin and Deckard_89 like this.
  32. BHS

    BHS

    Joined:
    Dec 21, 2009
    Posts:
    4,001
    Not currently, but that's a great idea. I'll add this to the list of features to add.
     
    julianr and ZGoodwin like this.
  33. BHS

    BHS

    Joined:
    Dec 21, 2009
    Posts:
    4,001
    Not currently as Emerald AI uses Unity's NavMesh. I have plans to add water/swimming support with a future update though.
     
    ZGoodwin likes this.
  34. julianr

    julianr

    Joined:
    Jun 5, 2014
    Posts:
    1,110
    Thanks. Would certainly make AI more realistic in their actions. List of possibilities would be endless...

    Target based events would be good too (event after target acquired, event after target lost, event after target is killed by this AI, event after target is killed by another AI, event after target is killed by this AI team number) - that sort of thing.
     
    BHS likes this.
  35. F0GZ

    F0GZ

    Joined:
    Feb 22, 2018
    Posts:
    25
    Sorry for that reply, but i need your help. I am in dead end now and actually dont know what to do.

    How can I resurrect AI after death?
    I use the object pool manager, and after death (deactivation) and the subsequent revival (activation), the AI behaves very strangely.

    I also tried a "ResetAI();" function, but this is doesn't work.
     
  36. o0neza0o

    o0neza0o

    Joined:
    Sep 6, 2015
    Posts:
    164
    Yeah, was wondering as i can only have 5 factions and i have many types of wildlife. Was also wondering if there was gonna be any feature to do with hunger and thirst. I don't mind doing one, if you are planning one. I might be able to help with it!
     
  37. BHS

    BHS

    Joined:
    Dec 21, 2009
    Posts:
    4,001
    There's currently a bug with AI being properly reset as the AI's default state is not set when the ResetAI function is called. This can be fixed by calling EmeraldAIBehaviors.DefaultState(); after calling the ResetAI function.
     
  38. BHS

    BHS

    Joined:
    Dec 21, 2009
    Posts:
    4,001
    I plan on adding more factions within the next couple of updates. I don't have plans for hunger and thirst, but they are good suggestions. I can certainly consider adding them to a future update.
     
  39. chrisk

    chrisk

    Joined:
    Jan 23, 2009
    Posts:
    511
    EmeraldAI is really good and works as expected when using through GUI but I find that GUI is too limited and it's hard to extend through the code. I hope it becomes more customizable by exposing APIs and such. If so, I can perhaps make it callable from external tools such as NodeCanvas.
    Please keep the good work.
     
  40. BHS

    BHS

    Joined:
    Dec 21, 2009
    Posts:
    4,001
    @FractalCore

    For those who'd like to damage an AI using PlayerMaker, I've figured out how to do so.

    1) Open up the EmeraldAISystem script and find the Damage function. For some reason, TargetType? TypeOfTarget = null does not play nicely with PlayMaker so you will need to make this change (I will add a function specifically for PlayMaker with the 2.2.2 update):
    Code (CSharp):
    1. public void Damage (int DamageAmount, TargetType? TypeOfTarget = null, Transform AttackerTransform = null, int RagdollForce = 100)
    To:
    Code (CSharp):
    1. public void Damage (int DamageAmount, TargetType TypeOfTarget, Transform AttackerTransform = null, int RagdollForce = 100)
    2) After creating your PlayMaker object, create 2 states; Detection, Get Component, and Damage. Next, create 2 variables; one EmeraldAISystem variable (this will be used to store the detected EmeraldAISystem component) and one GameObject called Target (this will be used to store the detected object)
    Variables.png


    3) You will need some way of detecting the target you would like to damage. For this example, I used a Trigger Event and stored the collider object as a new variable called Target (you will need to have a collider on your object and its Is Trigger set to true). You will want to make sure that the tag is set to your Emerald AI Unity Tag. You will need to transition to your Get Component state once you've created it.
    TriggerEvent.png


    3) Using a the Target object, get the EmeraldAISystem component using your EmeraldAISystem object you created to store it. Create a Send Event action to transition to the Damage state.
    GetComponent.png

    4) Create a Call Method and use the EmeraldAISystem object. This should allow you to select the Damage as the Method. Once you've done this, you will be able to set the Damage Amount, Target Type, Attacker Transform (which should be your PlayMaker object), and Ragdoll Force.
    CallMethod.png

    A very similar technique can be used to alter the AI's behavior (using the EmeraldAIBehaviors script) and the an AI's event manager (using EmeraldAIEventsManager script).
     
  41. SickaGamer

    SickaGamer

    Joined:
    Jan 15, 2018
    Posts:
    787
    Any updates coming to Emerald
     
  42. o0neza0o

    o0neza0o

    Joined:
    Sep 6, 2015
    Posts:
    164
    Ok, so as for hunger and thirst if i got a solution, i'll be the first to give you the information!
     
  43. westryder907

    westryder907

    Joined:
    Dec 28, 2016
    Posts:
    55
    I have an EmeraldAI + CTS(Complete Terrain Shader) setup and I can't get my EmeraldAI to spawn on the designated terrain texture. I've been trying to solve this for a couple weeks now, any help?

    I've tried disabling 'Strip textures' within CTS but no luck? What am I missing here?
     
  44. F0GZ

    F0GZ

    Joined:
    Feb 22, 2018
    Posts:
    25


    This errors always show in Console when i spawn enemies with this command:

    Code (CSharp):
    1. Instantiate(slowZombies[Random.Range(0, slowZombies.Length)], spawnPoints[Random.Range(0, spawnPoints.Length)].position, transform.rotation);
    NullReferenceException: Object reference not set to an instance of an object
    EmeraldAI.EmeraldAIBehaviors.ActivateCombatState () (at Assets/!ASSETSTOREKITS/Emerald AI/Scripts/Components/EmeraldAIBehaviors.cs:476)
    EmeraldAI.Utility.EmeraldAIDetection.DetectTarget (UnityEngine.GameObject C) (at Assets/!ASSETSTOREKITS/Emerald AI/Scripts/Components/EmeraldAIDetection.cs:164)
    EmeraldAI.Utility.EmeraldAIDetection.OnTriggerEnter (UnityEngine.Collider C) (at Assets/!ASSETSTOREKITS/Emerald AI/Scripts/Components/EmeraldAIDetection.cs:398)


    What can be a problem?
     
    Last edited: Jul 4, 2019
  45. jnbbender

    jnbbender

    Joined:
    May 25, 2017
    Posts:
    308
    I looked at one of the reviews and someone said the AI doesn't respond to sound. Is this true? It seems like the first thing an AI system would put in place. What is the real story?
     
  46. Mad_Mark

    Mad_Mark

    Joined:
    Oct 30, 2014
    Posts:
    386
    @jnbbender Emerald is not responsible for your weapons and sound FX. Do you see a lot of other AI systems providing hearing simulation? I know that ICE-Creature Control had a simple hearing implementation that was in essence a copy of its vision simulation with a larger arc, but ICE is no more.

    Sound detection is an advanced function (I hope it evolves into Emerald) that typically relies on integration with whatever is generating the sound. This is usually the weapons that the character is using. Each weapon will require a script that defines its sound range, potentially a physics sphere to cast for detection, and this can be extended to each object/entity in a level having an acoustic property (how well it allows, muffles, or blocks sound propagation), perhaps based on materials or tags. All of this equals overhead.

    The AI would then need yet another physics sphere to define its hearing range. If the originating object's sound range overlaps the detecting object's hearing range, and the objects in between don't cancel the sound, you have detection. There are a lot of dependencies.

    I'm doing it myself, but it is rudimentary. It doesn't consider anything between the originator and listener. No acoustics for echo or damping. I create a noise.cs script which watches the active weapon's audio source, and if isPlaying, sets the sound travel distance and checks for an AI hearing collider in range. Grenade goes off 50 units away, AI "hears" it. 5 x 1 unit walls in between player and AI? Doesn't matter. 50.1 units away? Nope, can't hear it. Not realistic, but it's just a game...

    Mark
     
  47. Deckard_89

    Deckard_89

    Joined:
    Feb 4, 2016
    Posts:
    202
    Is there some reason Emerald creatures use a box collider rather than capsule?
     
  48. pccross

    pccross

    Joined:
    Jun 20, 2015
    Posts:
    91
    So I've used Emerald on some past AI characters without issues. I have one new character I'm trying it on, that is having an issue. This character is rigged, but didn't have any existing animations. As soon as I created AI controller with Emerald, it correctly follows my player around, but it seems to have sunk below ground level and just moves around below ground level without any combat maneuvers or similar. Am I missing something?
     
  49. magique

    magique

    Joined:
    May 2, 2014
    Posts:
    3,632
    Whenever I see this, it usually turns out that the animator controller doesn't have the creature's avatar assigned.
     
  50. pccross

    pccross

    Joined:
    Jun 20, 2015
    Posts:
    91
    That definitely seemed to improve things.

    I am seeing a new issue though that's perplexing. So I changed the Animation Controller to be the stock Third Person Animator Controller (from Unity Standard Assets). Is there a conflict with Emerald and that controller? Whenever i go in the Animations tab and select a 'walk' animation, I immediately get a 'IndexOutofRangeException: Index was outside the bounds of the array'. Subsequently, the Animations tab disappears, and I can't adjust it. So I have to shutdown Unity, and no matter what animation I insert into that slot, I get that 'IndexOutofRange' Exception again.