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

    BHS

    Joined:
    Dec 21, 2009
    Posts:
    4,760
  2. BHS

    BHS

    Joined:
    Dec 21, 2009
    Posts:
    4,760
    Is there NavMesh generated around this 9 meter high object? If not, this would be why the AI can still attack your player.
     
  3. BHS

    BHS

    Joined:
    Dec 21, 2009
    Posts:
    4,760
    Additional colldiers are currently disabled to avoid interfering with the AI's line of sight. I plan on adding an option to not disable additional colliders soon to allow AI to have more accurate damage detection and location based damage.
     
    Deckard_89 likes this.
  4. Deckard_89

    Deckard_89

    Joined:
    Feb 4, 2016
    Posts:
    315
    Great, looking forward to it.
     
  5. BHS

    BHS

    Joined:
    Dec 21, 2009
    Posts:
    4,760
    You need to increase your AI's Expanded Chase Distance (located under Detection Options). When an AI is damaged with no detectable targets, it will expand its Chase Distance to the Expanded Chase Distance value to reach its set attack with Damage(50, EmeraldAI.EmeraldAISystem.TargetType.Player, TheSetTargetTransform);
     
  6. SickaGames1

    SickaGames1

    Joined:
    Jan 15, 2018
    Posts:
    1,268
    How do I get an AI to execute a series of movements and spells (within a specified radius) when they hit 20% life?
     
  7. BHS

    BHS

    Joined:
    Dec 21, 2009
    Posts:
    4,760
    Emotes are for non-combat. An AI will use its Combat Movement State for fleeing. Adding in an injured flee would require creating another Movement State, which I could add with future update. What you could do for now is switch the AI to the opposite Weapon Type when the AI starts to flee to utilize the additional Movement State, if you are not using both weapon types. You would need to apply all needed animations through the Emerald AI editor and call the following code:
    Code (CSharp):
    1. //Switch to Ranged
    2. GetComponent<EmeraldAI.EmeraldAISystem>().AIAnimator.SetInteger("Weapon Type State", 1);
    3. GetComponent<EmeraldAI.EmeraldAISystem>().WeaponTypeRef = WeaponType.Ranged;
    4.  
    5. //Switch to Melee
    6. GetComponent<EmeraldAI.EmeraldAISystem>().AIAnimator.SetInteger("Weapon Type State", 0);
    7. GetComponent<EmeraldAI.EmeraldAISystem>().WeaponTypeRef = WeaponType.Melee;
     
  8. BHS

    BHS

    Joined:
    Dec 21, 2009
    Posts:
    4,760
    This is because you need to bake the ramp with Unity's NavMesh. The NavMesh is what properly calculates an AI's distance from its target: https://docs.unity3d.com/Manual/nav-BuildingNavMesh.html
     
  9. p_hergott

    p_hergott

    Joined:
    May 7, 2018
    Posts:
    414
    Is there any plan to have a set or to be able to use emote animations while in combat state? Would be useful to script in special attacks
     
    SickaGames1 likes this.
  10. SickaGames1

    SickaGames1

    Joined:
    Jan 15, 2018
    Posts:
    1,268
    Please see my question @BHS
     
  11. unity_7UFP4-iCkwsgjg

    unity_7UFP4-iCkwsgjg

    Joined:
    Dec 13, 2017
    Posts:
    323
    everytime my player tries to damage my ai it states this AnimationEvent 'SendEmeraldDamage' has no receiver! Are you missing a component?
     
  12. p_hergott

    p_hergott

    Joined:
    May 7, 2018
    Posts:
    414
    The animation event has no receiver because the emerald ai scripts pick it up, your player doesnt have those. Easiest cleanest way ive found. Dont use the same animations on players as AI do. Make a copy of the animation.


    BHS. Whats the error for emeraldai render reference null about?
     
  13. unity_7UFP4-iCkwsgjg

    unity_7UFP4-iCkwsgjg

    Joined:
    Dec 13, 2017
    Posts:
    323
    ah right so use a different send event function like sendplayerdamage?
     
  14. sebasfreelance

    sebasfreelance

    Joined:
    Aug 27, 2015
    Posts:
    240
    thanks for your reply.

    but I'm still unsuccessful
    I have downloaded your asset in a new project
    I have well configured the navmesh, I attached image

    https://imgur.com/a/2OaOvSO

    https://imgur.com/a/ePuQKiB

    if you look at this last image, the player is taller, but the enemies continue to damage him
     
    Last edited: Sep 30, 2019
  15. p_hergott

    p_hergott

    Joined:
    May 7, 2018
    Posts:
    414
    The sendemeralddamage from the animation event, is just a notification and timing thing for the AI. Your player doesnt need those at all. But pending on how you are doing your players damage it could be done dozens of ways. I love animation events cause its easy to time everything.
     
  16. unity_7UFP4-iCkwsgjg

    unity_7UFP4-iCkwsgjg

    Joined:
    Dec 13, 2017
    Posts:
    323
    ah right so no function need in event?

    heres my damage script:

    Code (CSharp):
    1.     public float damage;
    2.  
    3.     private int hitRange = 1;
    4.  
    5.     public bool isDead = false;
    6.  
    7.  
    8.     private void Start()
    9.     {
    10.     }
    11.  
    12.  
    13.     void Update()
    14.     {
    15.         if (Input.GetKeyDown("e"))
    16.         {
    17.             Attack();
    18.  
    19.         }
    20.  
    21.  
    22.         void Attack()
    23.         {
    24.             RaycastHit hit;
    25.             Vector3 forward = transform.TransformDirection(Vector3.forward);
    26.             Vector3 origin = transform.position;
    27.  
    28.             if (Physics.Raycast(origin, forward, out hit, hitRange))
    29.             {
    30.                 if (hit.transform.gameObject.tag == "Player")
    31.                 {
    32.                     hit.transform.gameObject.SendMessage("PlayerDamage", 50);
    33.                     GetComponent<PlayerVitals>().curExp += 50;
    34.  
    35.                 }
    36.  
    37.  
    38.                 if (hit.transform.gameObject.tag == "Enemy")
    39.                 {
    40.                     hit.transform.gameObject.SendMessage("PlayerDamage", 50);
    41.                 }            
    42.  
    43.                 }
    44.  
    45.             }
    46.  
    47.  
    48.    
    49.  
    50.     }
     
  17. p_hergott

    p_hergott

    Joined:
    May 7, 2018
    Posts:
    414
    Ya, that style doesnt need animation events. The damage function if called when you hit a button.

    Mine for example, doesnt send damage when i hit a button, it just plays a animation. But on that animation, it has a event that triggers a script that enables a cone collider trigger, then check if a enemy is in that collider, then sends the damage to that enemy.
     
  18. unity_7UFP4-iCkwsgjg

    unity_7UFP4-iCkwsgjg

    Joined:
    Dec 13, 2017
    Posts:
    323
    ah right but how can i link the damage to my ai ?
     
  19. p_hergott

    p_hergott

    Joined:
    May 7, 2018
    Posts:
    414
    Sorry im not a coder, the emerald ai documents should be able to help you, or go into the emerald ai script to look around.

    public void Damage (int DamageAmount, TargetType? TypeOfTarget = null, Transform AttackerTransform = null, int RagdollForce = 100)

    I use playmaker. But thats a snippet from the script.
    I call the method of Damage to the AI emeraldai script, with the above parameters.
    But again, not a coder.
     
  20. BHS

    BHS

    Joined:
    Dec 21, 2009
    Posts:
    4,760
    I plan on adding more dynamic movement during combat as well as odds to cast each offensive ability soon. I'm not exactly sure how you would accomplish this through custom code at the moment. When I have some free time, I can look into this to see how it could be done.
     
  21. BHS

    BHS

    Joined:
    Dec 21, 2009
    Posts:
    4,760
    I could allow emote animations to play during combat, but they're more for non-combat animations. I plan on adding more attack animations and customizable odds to each ability. I also plan on having the ability to specify the animation used for each ability. This should allow for special attacks based on odds. To expand things further, I can look into adding a function to force a specified ability.
     
  22. BHS

    BHS

    Joined:
    Dec 21, 2009
    Posts:
    4,760
    What is the error? It most likely is due to having the Disable when Off-Screen feature enabled with no applied renderer.
     
  23. BHS

    BHS

    Joined:
    Dec 21, 2009
    Posts:
    4,760
    In your script you posted, replace this:
    Code (CSharp):
    1. if (hit.transform.gameObject.tag == "Enemy")
    2. {
    3.    hit.transform.gameObject.SendMessage("PlayerDamage", 50);
    4. }  
    With this:
    Code (CSharp):
    1. if (hit.transform.gameObject.tag == "Enemy")
    2. {
    3.    hit.transform.GetComponent<EmeraldAI.EmeraldAISystem>().Damage (damage, EmeraldAI.EmeraldAISystem.TargetType.Player, transform);
    4. }
     
  24. p_hergott

    p_hergott

    Joined:
    May 7, 2018
    Posts:
    414
    Hahaha free time
     
  25. p_hergott

    p_hergott

    Joined:
    May 7, 2018
    Posts:
    414
    Ah that makes sense, i was playing with that feature, testing.
     
  26. p_hergott

    p_hergott

    Joined:
    May 7, 2018
    Posts:
    414
    The disable when off screen and optimization, is that intend to disable and reenable the ai system? Or to destroy the unit?
     
  27. unity_7UFP4-iCkwsgjg

    unity_7UFP4-iCkwsgjg

    Joined:
    Dec 13, 2017
    Posts:
    323
    done that but it is still not registering an attack on my ai ?
     
  28. BHS

    BHS

    Joined:
    Dec 21, 2009
    Posts:
    4,760
    I've identified the issue with this and it will be fixed with the 2.3.0.2 update. Thanks for the bug report.
     
  29. BHS

    BHS

    Joined:
    Dec 21, 2009
    Posts:
    4,760
    I know. :(

    The disable when off screen system simply stops all Emerald AI scripts from running and stops the Animator Controller until the AI is visible or unculled. However, the AI's model is still visible.
     
  30. BHS

    BHS

    Joined:
    Dec 21, 2009
    Posts:
    4,760
    Are you using the right tags? Your script is using the Enemy tag so make sure your AI are using this tag.
     
  31. unity_7UFP4-iCkwsgjg

    unity_7UFP4-iCkwsgjg

    Joined:
    Dec 13, 2017
    Posts:
    323
    yep ai is using the Enemy tag. does the ai need any other components other then the emerald system?
     
  32. p_hergott

    p_hergott

    Joined:
    May 7, 2018
    Posts:
    414
    Off of memory BHS, if i alter the animator blend tree for movement, expanding the directional animations from a value of 90 to 150, is that gonna mess anything up in the code down the line? (Doing it for 1 model that has some pretty excessive turn animations, so it should blend more towards the move straight animation, little smoother for this one particular model)
     
  33. sebasfreelance

    sebasfreelance

    Joined:
    Aug 27, 2015
    Posts:
    240
    Thank you so much! I was going crazy doing tests;)

    Best regards
     
  34. Low_on_Mana

    Low_on_Mana

    Joined:
    Jun 18, 2018
    Posts:
    37
    Hi! I have a question about combat walk and run attacks (for two separate reasons)

    Combat Walk: When is this utilized? I want to have an AI use combat walk to approach a target until they're within X range and then switch to combat run.

    Run Attacks: Is there a way to force run attack the first time or whenever the AI reaches a target? I.E. I have an AI that chases other AI, but I would like it to perform its run attack upon reaching it (it's a jump attack type thing). Is this something I would have to do with normal attacks because the AI stops moving when it reaches its target and if so, could I make the range of the run attack longer than the distance of my normal attacks?

    Thanks!
     
  35. p_hergott

    p_hergott

    Joined:
    May 7, 2018
    Posts:
    414
    Would using run animations in the walk slots, and walk animations in the run slot not work. Use root motion for speed, or, if it allows, under the settings set walk speed to like 4 and run speed to like 1?
     
  36. p_hergott

    p_hergott

    Joined:
    May 7, 2018
    Posts:
    414
    BHS would be nice, in the future, to compliment the equip system, is to have a weapon rest position too. so 1 weapon activates, other deactivates.
     
  37. BHS

    BHS

    Joined:
    Dec 21, 2009
    Posts:
    4,760
    The AI shouldn't need anything extra. Just the Box Collider and Rigidbody components Emerald AI generates.
     
  38. SickaGames1

    SickaGames1

    Joined:
    Jan 15, 2018
    Posts:
    1,268
    Are you going to implement different colliders for different damage amounts? Ie heads is 2X damage ect..
     
  39. BHS

    BHS

    Joined:
    Dec 21, 2009
    Posts:
    4,760
    It shouldn't mess anything up. Have you tried using the Turn Angle value in the Movement Settings for making the turning less sensitive?
     
  40. unity_7UFP4-iCkwsgjg

    unity_7UFP4-iCkwsgjg

    Joined:
    Dec 13, 2017
    Posts:
    323
    ah right this is the damage script changed for player but still not damaging player


    Code (CSharp):
    1.         void Update()
    2.         {
    3.             if (Input.GetKeyDown("e"))
    4.             {
    5.                 Attack();
    6.  
    7.             }
    8.  
    9.  
    10.             void Attack()
    11.             {
    12.                 RaycastHit hit;
    13.                 Vector3 forward = transform.TransformDirection(Vector3.forward);
    14.                 Vector3 origin = transform.position;
    15.  
    16.                 if (Physics.Raycast(origin, forward, out hit, hitRange))
    17.                 {
    18.  
    19.                     if (hit.transform.gameObject.tag == "Enemy")
    20.                     {
    21.                         hit.transform.GetComponent<EmeraldAI.EmeraldAISystem>().Damage(damage, EmeraldAI.EmeraldAISystem.TargetType.Player, transform);
    22.                     }
    23.  
    24.  
    25.                 }
    26.  
    27.             }
    28.  
     
  41. p_hergott

    p_hergott

    Joined:
    May 7, 2018
    Posts:
    414
    Also for the patch if you haven't already have it. the warning animation. if you enable warning animation. and have a AI that is only ranged. the warning animation slot is for melee warning not ranged. but if you then switch to "Both" it shows both the melee warning and ranged warning animation slots.
     
  42. magique

    magique

    Joined:
    May 2, 2014
    Posts:
    4,030
    @BHS It looks like the new version is missing some code. I added Attack sounds to my AI and the sounds never play. So, I did some checking in the code and the PlayAttackSound function is no longer called anywhere in the system. I'm going to try to figure out where it should go, but if you answer before I find it that would be great.

    [EDIT]
    OK, so I stumbled across the ability to call PlayAttackSound in the OnAttackEvent. So, I think all is well.
     
    Last edited: Oct 1, 2019
  43. p_hergott

    p_hergott

    Joined:
    May 7, 2018
    Posts:
    414
    I think someone should start a “AA group”. For Assets anonymous.
     
    FrostedBrain likes this.
  44. MagiSoftworks

    MagiSoftworks

    Joined:
    Feb 12, 2019
    Posts:
    124
  45. FrostedBrain

    FrostedBrain

    Joined:
    Sep 26, 2019
    Posts:
    31
    I'm using the collision propagators asset to damage emerald ai agents with bullet projectiles from a VR weapon. The asset allows me to use events to trigger stuff on collision. I am using it on my bullets and AI agents.

    So far I can do "EmeraldAIEventsManager>KillAI" and the bullet will kill the AI.

    How can I send a specific amount of damage using events?

    I tried "EmeraldAISystem>SendEmeraldDamage" but that didnt seem to do anything to my AI when I shot them
     
  46. BHS

    BHS

    Joined:
    Dec 21, 2009
    Posts:
    4,760
    Double check that your Raycast is firing in the correct direction. This is most likely what isn't working. Do a Debug.Log(hit.gameObject.name); to make sure the raycast is hitting where you want it to hit.
     
  47. BHS

    BHS

    Joined:
    Dec 21, 2009
    Posts:
    4,760
    Thanks for the bug report. I'll fix this with the 2.3.0.2 update.
     
    SickaGames1 likes this.
  48. BHS

    BHS

    Joined:
    Dec 21, 2009
    Posts:
    4,760
    OnAttackEvent can be used, but PlayAttackSound is intended for an Animation Event. This allows you to control the exact frame the attack sound will happen, but if you just need it to play when the attack animation is played, an OnAttackEvent is perfectly fine.
     
  49. BHS

    BHS

    Joined:
    Dec 21, 2009
    Posts:
    4,760
    Hey there! I update the code when needed. So, if the Invector tutorial video shows different code, it's only because the code snippets have been updated to work with the newest version of Invector.
     
  50. BHS

    BHS

    Joined:
    Dec 21, 2009
    Posts:
    4,760
    To damage an AI, you need to use the Damage function like this:
    Code (CSharp):
    1. if (YourCollisionObject.GetComponent<EmeraldAI.EmeraldAISystem>())
    2. {                
    3.    YourCollisionObject.GetComponent<EmeraldAI.EmeraldAISystem>().Damage((int)YourDamageAmount, EmeraldAI.EmeraldAISystem.TargetType.Player,  YourPlayerTransform, 600);
    4. }