Search Unity

[SALE 50% OFF] Emerald AI 3.0 (New HUGE Update) - The Ultimate Universal AAA Quality AI Solution

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

?

Which main feature would you like to see in the upcoming 2.6 Emerald AI update?

  1. Strafing - Allow AI to strafe in circles around their targets within a customizable distance.

    22.1%
  2. Stats - Allow AI to have additional stats, such as stamina and mana, usable by an AI's abilities.

    22.1%
  3. Sound Detection - Allow AI to detect sounds within a certain distance of their position.

    55.9%
  1. BHS

    BHS

    Joined:
    Dec 21, 2009
    Posts:
    4,514
    The OnStartCombat event is only invoked once at the start of combat. It is only invoked again once an enemy has left its combat state and it then re-enters it.

    I've been wanting to rework the OnAttack event as it is essentially the same thing as the OnDoDamage event, minus actually dealing damage. What I could do is make OnAttack event OnAttackStart and have this invoked when the current attack animation starts and then invoke a new event called OnAttackEnd once the AI's attack has concluded. The problem with all this is that it can all be handled with an Animation Event. I guess this would make it easier as it wouldn't require making Animation Events for every animation and it could offer some added functionality. I tested this though and it was able to reliably enable and disable a collider as you were trying to do. I think the problem was that OnStartCombat is only called once.
     
  2. BHS

    BHS

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

    BHS

    Joined:
    Dec 21, 2009
    Posts:
    4,514
  4. SickaGamer

    SickaGamer

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

    BHS

    Joined:
    Dec 21, 2009
    Posts:
    4,514
    julianr, Bioman75 and SickaGamer like this.
  6. wood333

    wood333

    Joined:
    May 9, 2015
    Posts:
    780
    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?
     
  7. TheCaveOfWonders

    TheCaveOfWonders

    Joined:
    Mar 2, 2014
    Posts:
    7
    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 ?
     
  8. Darrkbeast

    Darrkbeast

    Joined:
    Mar 26, 2013
    Posts:
    119
    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.
     
  9. 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
     
  10. ecarter

    ecarter

    Joined:
    Jan 3, 2013
    Posts:
    16

    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
     
  11. moltke

    moltke

    Joined:
    Apr 28, 2019
    Posts:
    96
    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?
     
  12. raulrusboy

    raulrusboy

    Joined:
    Apr 20, 2020
    Posts:
    6
    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.
     
  13. jnbbender

    jnbbender

    Joined:
    May 25, 2017
    Posts:
    420
    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.

     
  14. trojant

    trojant

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

    SickaGamer

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

    mattis89

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

    Bioman75

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

    mattis89

    Joined:
    Jan 10, 2017
    Posts:
    1,146
  19. BHS

    BHS

    Joined:
    Dec 21, 2009
    Posts:
    4,514
    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?
     
  20. BHS

    BHS

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

    BHS

    Joined:
    Dec 21, 2009
    Posts:
    4,514
    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;
     
  22. BHS

    BHS

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

    BHS

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

    SickaGamer

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

    BHS

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

    BHS

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

    BHS

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

    BHS

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

    BHS

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

    moltke

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

    Bioman75

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

    mattis89

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

    mattis89

    Joined:
    Jan 10, 2017
    Posts:
    1,146
    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.
     
  34. mattis89

    mattis89

    Joined:
    Jan 10, 2017
    Posts:
    1,146
    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.....?
     
  35. 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
  36. wood333

    wood333

    Joined:
    May 9, 2015
    Posts:
    780
    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.
     
  37. Deckard_89

    Deckard_89

    Joined:
    Feb 4, 2016
    Posts:
    306
    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.
     
  38. wood333

    wood333

    Joined:
    May 9, 2015
    Posts:
    780
    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.
     
  39. SickaGamer

    SickaGamer

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

     
    dsilverthorn and Bioman75 like this.
  40. raulrusboy

    raulrusboy

    Joined:
    Apr 20, 2020
    Posts:
    6
    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?
     
  41. 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.
     
  42. 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:

  43. Deckard_89

    Deckard_89

    Joined:
    Feb 4, 2016
    Posts:
    306
    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).
     
  44. 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.
  45. 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.
     
  46. raulrusboy

    raulrusboy

    Joined:
    Apr 20, 2020
    Posts:
    6
    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...
     
  47. SickaGamer

    SickaGamer

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

    BHS

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

    BHS

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

    BHS

    Joined:
    Dec 21, 2009
    Posts:
    4,514
    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.
unityunity