Search Unity

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

[RELEASED] Emerald AI 3.2 (New Sound Detection) - 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:
    236
  2. magique

    magique

    Joined:
    May 2, 2014
    Posts:
    4,030
  3. gearedgeek

    gearedgeek

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

    magique

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

    magique

    Joined:
    May 2, 2014
    Posts:
    4,030
    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
  6. gearedgeek

    gearedgeek

    Joined:
    Jun 19, 2015
    Posts:
    236
    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.
     
  7. magique

    magique

    Joined:
    May 2, 2014
    Posts:
    4,030
    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.
     
  8. gearedgeek

    gearedgeek

    Joined:
    Jun 19, 2015
    Posts:
    236
    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:
      724
    • 2.PNG
      2.PNG
      File size:
      264.3 KB
      Views:
      724
    • 3.PNG
      3.PNG
      File size:
      31.4 KB
      Views:
      710
  9. magique

    magique

    Joined:
    May 2, 2014
    Posts:
    4,030
    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?
     
  10. gearedgeek

    gearedgeek

    Joined:
    Jun 19, 2015
    Posts:
    236
    @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.
     
  11. magique

    magique

    Joined:
    May 2, 2014
    Posts:
    4,030
    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.
     
  12. BHS

    BHS

    Joined:
    Dec 21, 2009
    Posts:
    4,760
    ZGoodwin likes this.
  13. BHS

    BHS

    Joined:
    Dec 21, 2009
    Posts:
    4,760
    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.
     
  14. BHS

    BHS

    Joined:
    Dec 21, 2009
    Posts:
    4,760
    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.
  15. BHS

    BHS

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

    BHS

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

    BHS

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

    BHS

    Joined:
    Dec 21, 2009
    Posts:
    4,760
    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.
  19. BHS

    BHS

    Joined:
    Dec 21, 2009
    Posts:
    4,760
    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.
  20. Deckard_89

    Deckard_89

    Joined:
    Feb 4, 2016
    Posts:
    315
    @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
  21. julianr

    julianr

    Joined:
    Jun 5, 2014
    Posts:
    1,212
    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 :)
     
  22. tahir_ali

    tahir_ali

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

    huntersteeger

    Joined:
    Dec 27, 2017
    Posts:
    19
    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.
  24. o0neza0o

    o0neza0o

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

    adifrank

    Joined:
    Dec 11, 2017
    Posts:
    26
    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?
     
  26. o0neza0o

    o0neza0o

    Joined:
    Sep 6, 2015
    Posts:
    165
    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?
     
  27. BHS

    BHS

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

    BHS

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

    BHS

    Joined:
    Dec 21, 2009
    Posts:
    4,760
    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.
  30. julianr

    julianr

    Joined:
    Jun 5, 2014
    Posts:
    1,212
    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.
  31. F0GZ

    F0GZ

    Joined:
    Feb 22, 2018
    Posts:
    33
    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.
     
  32. o0neza0o

    o0neza0o

    Joined:
    Sep 6, 2015
    Posts:
    165
    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!
     
  33. BHS

    BHS

    Joined:
    Dec 21, 2009
    Posts:
    4,760
    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.
     
    hessex likes this.
  34. BHS

    BHS

    Joined:
    Dec 21, 2009
    Posts:
    4,760
    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.
     
  35. chrisk

    chrisk

    Joined:
    Jan 23, 2009
    Posts:
    704
    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.
     
  36. BHS

    BHS

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

    For those who'd like to damage an AI using PlayMaker, 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).
     
    Last edited: Mar 5, 2023
    hessex likes this.
  37. SickaGames1

    SickaGames1

    Joined:
    Jan 15, 2018
    Posts:
    1,268
    Any updates coming to Emerald
     
  38. o0neza0o

    o0neza0o

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

    westryder907

    Joined:
    Dec 28, 2016
    Posts:
    61
    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?
     
  40. F0GZ

    F0GZ

    Joined:
    Feb 22, 2018
    Posts:
    33


    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
  41. jnbbender

    jnbbender

    Joined:
    May 25, 2017
    Posts:
    486
    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?
     
  42. Mad_Mark

    Mad_Mark

    Joined:
    Oct 30, 2014
    Posts:
    484
    @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
     
  43. Deckard_89

    Deckard_89

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

    pccross

    Joined:
    Jun 20, 2015
    Posts:
    106
    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?
     
  45. magique

    magique

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

    pccross

    Joined:
    Jun 20, 2015
    Posts:
    106
    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.
     
  47. magique

    magique

    Joined:
    May 2, 2014
    Posts:
    4,030
    You can't just replace the controller. Emerald builds a specific controller based on the animations you've selected when you create the AI.
     
  48. pccross

    pccross

    Joined:
    Jun 20, 2015
    Posts:
    106
    I kind of thought that based on my past experience. I can't figure out why none of the other controllers cause my player to sink into the ground, only the Emerald AI controller causes it.
    It seems similar to this issue:
    https://answers.unity.com/questions/398465/character-falls-thru-to-his-waist.html

    That link alludes to what you mentioned earlier about the missing avatar. But that is fixed now, and I'm still having the same issue. It mentions possibly removing a 'bad' Idle animation from the controller.
    How would I remove that from the controller Emerald creates?
     
  49. magique

    magique

    Joined:
    May 2, 2014
    Posts:
    4,030
    You should verify that your idle animation actually works with your AI character. If you click on the animation and hit play in the inspector preview, does it work? You can drag the fbx model of the character into the preview to make sure it is previewing the character you are using the animation for.

    It might be that you have the animation using a different avatar than the one your AI is assigned to as well. Or that the animation is Legacy and needs to be Generic or Humanoid.
     
  50. Mad_Mark

    Mad_Mark

    Joined:
    Oct 30, 2014
    Posts:
    484
    Click on your character in scene, and click on the animator controller in the animator field. It should show you the animator controller in the hierarchy. If you click / double click on that, it should open the animator window and from there you can click on the idle animation holders. Each will show the animation that is assigned.

    I would look for animations that are either blank or not set to humanoid. Assigning a Legacy or Generic animation to a Humanoid character results in "the fetal position". Knees come up, arms are bent, Y position sinks down....