Search Unity

[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. BHS

    BHS

    Joined:
    Dec 21, 2009
    Posts:
    4,764
    Version 2.4.2.1 has been submitted and is awaiting approval. This update addresses some of the issues that the location based damage feature introduced as well as some general bug fixes and improvements.

    The next main update, version 2.4.3, will add strafing to both ranged and melee AI.

    Improvements
    • Added Dynamic Waypoint Wander Layers LayerMask to the Emerald AI Editor (Located under Temperament>Wander Type Settings) to choose which layers will be detected when generating dynamic waypoints. By default, this is set to Everything.
    • Added an error message that's displayed in the Unity Console if an AI has a Faction Relation of Enemy that is also their current Faction as this led to incorrect target detection.
    • Added ChangeFaction to Emerald AI's API that can change an AI's faction, given that it exists in the Faction Manager.
    • Added CheckForPlayerDetection to Emerald AI's API that returns true if the player is currently detected within the AI's detection radius.
    • Added DebugLogMessage to Emerald AI's API that allows users to pass a message that's visible within the Unity Console.
    • Added GetDistanceFromTarget to Emerald AI's API that gets the distance between the AI and its current target.
    • Added EnableObject to Emerald AI's API that enables the passed gameobject.
    • Added DisableObject to Emerald AI's API that disables the passed gameobject.
    • Reworked the OnAttack event to be OnAttackStart event. This fires an event when the AI's attack animation starts playing. This event often lead to confusion. This rework, along with the addition of OnAttackEnd, should increase functionality and make the two events more clear with what they do.
    • Added OnAttackEnd event. This fires an event when the AI's attack animation ends playing. Note: This event only works for Melee weapon types.
    • Updated the Offline Documentation so the link to the Online Version goes to the Emerald AI Wiki and not the outdated online documentation.

    Bug Fixes
    • Stopped dynamic waypoints from detecting IsTrigger colliders as they often interfered with generating waypoints reliably.
    • Fixed an error that would sometimes happen when using the LocationBasedDamage component.
    • Fixed a bug that didn't allow an AI to take damage if it was the child of another object.
    • Fixed an issue that would sometimes happen if there was a rigidbody attached to an AI and the AI was using LocationBasedDamage.
    • Fixed a bug that would sometimes allow an AI's projectiles to collide with its own colliders, when using the LocationBasedDamage component.
    • Fixed a bug that stopped brave AI to not reset their behavior back to brave when returning to their starting position.
    • Updated the description of the Obstruction Ignore Layers setting.
    • Updated the description of the OnStartCombat event.
     
    Last edited: May 1, 2021
    Bioman75, timerace and EN_Games like this.
  2. BHS

    BHS

    Joined:
    Dec 21, 2009
    Posts:
    4,764
  3. SickaGames1

    SickaGames1

    Joined:
    Jan 15, 2018
    Posts:
    1,270
    It's good to have you back @BHS
     
    BHS likes this.
  4. BHS

    BHS

    Joined:
    Dec 21, 2009
    Posts:
    4,764
    julianr, Bioman75 and SickaGames1 like this.
  5. wood333

    wood333

    Joined:
    May 9, 2015
    Posts:
    851
    This is a good idea. Please, however consider my other issue. When I place a trigger collider on an Emerald AI NPC, Emerald blocks its operation. How do I add a trigger collider to an Emerald NPC so that Emerald Does not conflict with it?
     
  6. TheCaveOfWonders

    TheCaveOfWonders

    Joined:
    Mar 2, 2014
    Posts:
    27
    Very interested in this Asset, my project is built with the new Unity MLAPI for multiplayer support, I was wondering if I'd be able to integrate Emerald AI with that, basically everything will run server side and the clients will mostly get Transform and Animator updates among other things.

    MLAPI has a NetworkTransform and a NetworkAnimator behaviors for doing the syncing.

    Do you think that would be feasible ?
     
  7. Darrkbeast

    Darrkbeast

    Joined:
    Mar 26, 2013
    Posts:
    125
    Line of site issue

    Hi, so I set some AI behaviors via scripts. I have some scripts that make the AI passive. The AI starts off aggressive for context. When I set the ai to be passive while using Line of site it will still attack the player. If I change to trigger it works as intended.

    Is there a different way to pacify a Line of site enemy.
     
  8. goblinsrus4

    goblinsrus4

    Joined:
    Sep 30, 2014
    Posts:
    1
    hi got a slight issue im using mixamos zombie animations with root animation when i use the walk animation solo on charactor it walks as expected but if i use the same animation in emerald ai its not useing root motion as i selected its acting like a navmesh sliding in between steps
     
  9. ecarter

    ecarter

    Joined:
    Jan 3, 2013
    Posts:
    21

    hello , did you do that in to the pluging? i really need these feature, to make enemies follow player is make too much noise, or maybe if the player trown something to make noise in order to distract enemies
     
  10. moltke

    moltke

    Joined:
    Apr 28, 2019
    Posts:
    109
    Do you have a sound slot that when the monster detects a player in its radius it makes a sound

    like an aggro sound

    where a bear growls when it starts to chase a player?
     
  11. raulrusboy

    raulrusboy

    Joined:
    Apr 20, 2020
    Posts:
    9
    So, after almost a year using this, I've finally worked out all the self-inflicted bugs haha... But now I have a question that inspecting the code more closely doesn't seem to be able to answer- is it possible to delete an object and all it's clones from the object pool? I have an AI that isn't used after a certain point, and would like to dispose of all the inactive copies sitting in the object pool doing nothing.
     
  12. jnbbender

    jnbbender

    Joined:
    May 25, 2017
    Posts:
    487
    I am having an issue where my bullet only travels so far before it "explodes". It is not hitting any collider. I've attached the video so maybe someone can shed some light.

     
  13. trojant

    trojant

    Joined:
    May 8, 2015
    Posts:
    89
    Hi,Can AI walk or run randomly? Or by a certain rule. It looks like animals in nature.Thank you.
     
  14. SickaGames1

    SickaGames1

    Joined:
    Jan 15, 2018
    Posts:
    1,270
    You can write your own script to do it
     
  15. mattis89

    mattis89

    Joined:
    Jan 10, 2017
    Posts:
    1,151
    Hi! After latest update my AI dont attack. @BHS answer my email.. astralstormgames
     
  16. Bioman75

    Bioman75

    Joined:
    Oct 31, 2014
    Posts:
    92
    How can I get the player gameobject that damaged the ai?
     
  17. mattis89

    mattis89

    Joined:
    Jan 10, 2017
    Posts:
    1,151
  18. BHS

    BHS

    Joined:
    Dec 21, 2009
    Posts:
    4,764
    When you say Emerald AI blocks the collider's operation, do you mean the collider is disabled or it is not properly colliding? I have tested this and had no issues with a trigger collider detecting trigger collisions while attached to an AI. Was the setup for this with an AI using a trigger collider to cause damage to another AI when using the attack events?
     
  19. BHS

    BHS

    Joined:
    Dec 21, 2009
    Posts:
    4,764
    I haven't tested Emerald AI myself with multiplayer, but I do know it's possible to add support as other users have made it work with PUN2 and Mirror. If the other two network systems work, everything should work fine with Unity MILAPI.
     
  20. BHS

    BHS

    Joined:
    Dec 21, 2009
    Posts:
    4,764
    This is actually a bug.

    To fix this, open the EmeraldAIDetection script and find the line:
    Code (CSharp):
    1. if (EmeraldComponent.DetectionTypeRef == EmeraldAISystem.DetectionType.LineOfSight && EmeraldComponent.OptimizedStateRef == EmeraldAISystem.OptimizedState.Inactive && EmeraldComponent.CombatStateRef == EmeraldAISystem.CombatState.NotActive)
    Within this if statement, add the following line of code above LineOfSightDetection();. The Pet and Passive behaviors should not be using the Line of Sight feature.
    Code (CSharp):
    1. if (EmeraldComponent.BehaviorRef == EmeraldAISystem.CurrentBehavior.Passive || EmeraldComponent.BehaviorRef == EmeraldAISystem.CurrentBehavior.Pet)
    2.    return;
     
  21. BHS

    BHS

    Joined:
    Dec 21, 2009
    Posts:
    4,764
    Did you enable Root Motion through the Emerald AI editor as explained here? https://github.com/Black-Horizon-Studios/Emerald-AI/wiki/Setting-up-an-AI's-Animations#step-6
     
  22. BHS

    BHS

    Joined:
    Dec 21, 2009
    Posts:
    4,764
    Yes, this is explained here: https://github.com/Black-Horizon-Studios/Emerald-AI/wiki/Using-Emerald-AI's-Built-in-Object-Pool
     
  23. SickaGames1

    SickaGames1

    Joined:
    Jan 15, 2018
    Posts:
    1,270
    When is the strafing coming out :)
     
  24. BHS

    BHS

    Joined:
    Dec 21, 2009
    Posts:
    4,764
    Enable Debug Log Projectile Collisions within Debugging Tools as explained here (if you don't already have it enabled): https://github.com/Black-Horizon-Studios/Emerald-AI/wiki/Enabling-an-AI's-Debug-Tools

    This will display what the projectile may be colliding with to the Unity Console.

    The projectiles towards the later part of the video look like they're exploding because the destroy seconds is only 2 seconds, which isn't allowing the projectile to reach its target. I'm not sure what's going on with the first series of collisions. Double check that it's not colliding with anything using Debug Log Projectile Collisions as explained above.
     
  25. BHS

    BHS

    Joined:
    Dec 21, 2009
    Posts:
    4,764
    You can change the AI's movement state using the code below (given that you have a reference to the AI's EmeraldAISystem).

    Code (CSharp):
    1. //Run
    2. EmeraldComponent.CurrentMovementState = EmeraldAISystem.MovementState.Run;
    3.  
    4. //Walk
    5. EmeraldComponent.CurrentMovementState = EmeraldAISystem.MovementState.Walk;
     
    trojant likes this.
  26. BHS

    BHS

    Joined:
    Dec 21, 2009
    Posts:
    4,764
    Currently, the only way you can get the current attacker is by using the AttackerTransform variable within the Damage function within the EmeraldAISystem script.

    I've added a function within the EmeraldAIEventsManager that will return the transform of the last attacker for the next update though to make things easier.
     
    julianr likes this.
  27. BHS

    BHS

    Joined:
    Dec 21, 2009
    Posts:
    4,764
    I wasn't aware Root Motion isn't working, I'll look into it.
     
  28. BHS

    BHS

    Joined:
    Dec 21, 2009
    Posts:
    4,764
    I don't quite have an ETA for it yet :)
     
    julianr likes this.
  29. moltke

    moltke

    Joined:
    Apr 28, 2019
    Posts:
    109
    I was wondering if there was a way that this can be done?
     
  30. Bioman75

    Bioman75

    Joined:
    Oct 31, 2014
    Posts:
    92
    ETA on update?
     
  31. mattis89

    mattis89

    Joined:
    Jan 10, 2017
    Posts:
    1,151
    Thank you ! Also look at my email, im getting nowhere atm with this game .
     
  32. mattis89

    mattis89

    Joined:
    Jan 10, 2017
    Posts:
    1,151
    This don't fix the skating issue, when using rootmotion, if I change the navmesh speed when using rootmotion like the way you said, the animation also changes speed, and the ai behaves slowly. I want to say that I use rootmotion and it's set to rootmotion and it works fine if I set acceleration to 0 but then ai don't evade objects..no pathfinder.
     
  33. mattis89

    mattis89

    Joined:
    Jan 10, 2017
    Posts:
    1,151
    Also, when using rootmotion , when the AI sees the player nav agent speed goes from 0.1 to 1 ... Why? even if I use rootmotion and speed is the lowest 0.5 on non combat and combat and run also on 0.5.....?
     
  34. Devildanger

    Devildanger

    Joined:
    Mar 7, 2019
    Posts:
    1
    When assigning both combat types (so melee and ranged), you can't assign combat animations.

    Also I have prefabs that have 3 head objects that get activated randomly at the start. So for 1 instantiated prefab it's headA another instantiated one will use headB. But the head assigned to the HeadTransform in de the inspector might be turned inactive. Do you have a solution for this? Or will this not work for that model?
     
    Last edited: May 20, 2021
  35. wood333

    wood333

    Joined:
    May 9, 2015
    Posts:
    851
    1. The trigger collider shows active in the Unity inspector.
    2. No. The trigger is not set up for Ai to Ai damage. I use it only for Ai to Player damage. It uses a system separate and distinct from Emerald. So far it works with everything in my project not parented to an Emerald Ai NPC,( test cubes, campfire, Invector stuff, etc.). It does work on an Emerald arrow, I imagine because the arrow is not attached to an Emerald Ai NPC, but flys free.
     
  36. Deckard_89

    Deckard_89

    Joined:
    Feb 4, 2016
    Posts:
    316
    You need to manually re-enable the collider when your AI activates in the scene, because Emerald automatically deactivates all other colliders when the object is activated.
     
  37. wood333

    wood333

    Joined:
    May 9, 2015
    Posts:
    851
    Tried it days ago. No effect. It does not matter whether the collider is enabled or not. But thank you for taking the time to make the suggestion.
     
  38. SickaGames1

    SickaGames1

    Joined:
    Jan 15, 2018
    Posts:
    1,270
    Game trailer that use 100% Emerald AI with some modifications here and there:

     
    dsilverthorn and Bioman75 like this.
  39. raulrusboy

    raulrusboy

    Joined:
    Apr 20, 2020
    Posts:
    9
    Umm... No it's not... That's an explanation on how to spawn and despawn. I want to know how to completely remove an object that I will never use again in the scene, and all its copies from the object pool.

    Additionally, I keep getting a null reference exception on line 1843 of EmeraldAISystem (in Create Emerald Projectile). I'm 99% sure everything is assigned, but what's the best way to figure out what exactly is missing and why?
     
  40. Rahd

    Rahd

    Joined:
    May 30, 2014
    Posts:
    324
    Yes , i stopped coding it and moved on to other things , But here is the short logic of what i did (i don't have the code with me right now this is from 8 month old memory) :.
    on the player script i added values of detection , i was working on a shooter game so here are the things that makes noise :
    Armor have noise value , the lighter the less noise it makes
    Guns are loud in general unless you have a suppressor , plus subsonic ammo
    foot steps , depends on the foot wear you have and if he is running or sneaking slowly
    and health , when health is low player is in agony mode , so makes loud hurting noise
    an more stuff like when crouching
    ----------
    all of those values contribute to the final noise value of the player that is represented with a triggered collider Sphere
    the larger the value the bigger is the collider diameter .

    on the other side the Ai script have a collider of hearing , depending on the settings the collider will be bigger or smaller.
    a simple on trigger enter , will change the Ai target to the player or other Ai rivals .

    so to simplify 2 trigger Sphere colliders
    with on on trigger enter on the Ai , when that even happens you just change the target to the player and the state to aggressive i think ... the chasing will be done by the original Ai script as it's perfect .
    there is more to this i remember adding cones for directional noise with guns and melee
    and when crouching it's a circle collider ... and alot more stuff .
    good luck , i might get back to toying with it as this AI have a lot of expanding potential.
     
  41. alsoknownas-stefan

    alsoknownas-stefan

    Joined:
    Apr 3, 2020
    Posts:
    11
    I have a problem with Emerald AI 2.4.2. The line of sight option does not seem to be functioning correctly.

    See screenshots. I want to play the interact sound with ID 0 (Sounds > Interact Sounds) when the player comes into the line of sight cone. To do this, I call EmeraldAIEventsManager.PlayRandomSoundEffect() on the Player Detection Event in AI's Settings > Events > General. When I approach the NPC from the front, the sound is played. But when I approach the NPC from behind, outside of the line of sight cone, the sound is also played. This leads me to conclude that the line of sight cone is broken or does not function in combination with my configuration.

    What am I doing wrong?

    A second question: If I have multiple actions on Player Detection Event (), will they be executed from top to bottom or in a different order?
     

    Attached Files:

  42. Deckard_89

    Deckard_89

    Joined:
    Feb 4, 2016
    Posts:
    316
    Don't worry, line of sight does work. However, detection radius is a separate thing and your player actually counts as detected just by entering this radius. If you want to do stuff when entering line of sight, do it on OnStartCombat event instead (if it is an enemy of course. If it is a "normal" or friendly npc then I'm not sure how to go about that).
     
  43. MajorThurman

    MajorThurman

    Joined:
    Jan 3, 2020
    Posts:
    6
    For the last two days I have been trying to set up a simple Melee/Ranged attack AI using Emerald. Emerald version 2.4.2.1 Uniuty 2019.4.25. I have followed the documentation word for word and have attempted a setup from scratch approx 10 times now and every time I get the same outcome. The AI works fine when AI is in Melee attack mode but when it tried to do a ranged attack it gets stuck in a idle loop and never actually starts the shoot animation I have setup or fire the projectile I have setup using the ability function. I'm beyond frustarted. I have aksed for help in the discord but no one was able to help and have reported a bug to the developer. I'm now here as I have no where else to turn and I need to get an AI prototype out quickly for a project. Can anybody help please? Here is a screen shot of the debug. The only nav mesh I have setup is a flat plane for testing, no obstructions.
     

    Attached Files:

    MonstaManly likes this.
  44. MajorThurman

    MajorThurman

    Joined:
    Jan 3, 2020
    Posts:
    6
    Update
    - It now looks like our Physics VR player controller is what is causing the AI from shooting because of the colliders we have set up on the hands for physics/force grab. Maybe useful for anyone else having issues trying to use Emerald in a similar environment. I'll keep updating this post as we work to fix the issue.
     
  45. raulrusboy

    raulrusboy

    Joined:
    Apr 20, 2020
    Posts:
    9
    Btw, this is using a generic avatar (because it's a tank)- the headlook option is turned off, but I'm guessing that may be a factor...
     
  46. SickaGames1

    SickaGames1

    Joined:
    Jan 15, 2018
    Posts:
    1,270
    @BHS Any news on the next update?
     
  47. BHS

    BHS

    Joined:
    Dec 21, 2009
    Posts:
    4,764
    I plan on submitting a small update sometime next week that will fix a few bugs, add a few improvements, and add some new API to the EmeraldAIEventsManager, including the GetAttacker function.
     
  48. BHS

    BHS

    Joined:
    Dec 21, 2009
    Posts:
    4,764
    I'm not sure what you mean as Combat Animations for both weapon types are working fine on my end. Can you please provide a screenshot of what's happening?

    As for the head transform, you should be able to change this as needed by assigning a transform to the HeadTransform directly with:
    Code (CSharp):
    1. EmeraldComponent.HeadTransform = YourHeadTransform;
    CombatAnimations.png
     
  49. BHS

    BHS

    Joined:
    Dec 21, 2009
    Posts:
    4,764
    I've tested this and I was able to get an AI to damage the player using a trigger collider located within an AI on its weapon. When not using Location Based Damage, all internal colliders are disabled. You can override this by using the script below. There is an option to grab all colliders automatically or you can just assign them manually (which is most likely what you want). This will re-enable the specified colliders after Emerald AI has disabled them.

    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4.  
    5. public class EmeraldColliderOverride : MonoBehaviour
    6. {
    7.     public bool AutoGetColliders = false;
    8.     public List<Collider> ColliderList = new List<Collider>();
    9.  
    10.     private void Start()
    11.     {
    12.         Invoke("OverrideEmeraldColliders", 0.01f);
    13.     }
    14.  
    15.     /// <summary>
    16.     /// Enables the colliders from the ColliderList that Emerald AI disables.
    17.     /// </summary>
    18.     void OverrideEmeraldColliders ()
    19.     {
    20.         if (AutoGetColliders)
    21.             ColliderList = new List<Collider>(GetComponentsInChildren<Collider>());
    22.  
    23.         for (int i = 0; i < ColliderList.Count; i++)
    24.         {
    25.             ColliderList[i].enabled = true;
    26.         }
    27.     }
    28. }
     
    wood333 likes this.
  50. BHS

    BHS

    Joined:
    Dec 21, 2009
    Posts:
    4,764
    If you want to completely remove an object never to be used again, even when using Emerald AI's Object Pooling, then just destroy it with Destroy(YourGOToDestroy); . You will need to keep track of the objects you've spawned and then want destroyed. Simply storing them to a List should be enough. When you are ready to remove them, use a for loop to go through the list and destroy all objects within that list.

    The error seems like you may be missing an ability within your Offensive Abilities list.