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

    domhuff26

    Joined:
    Mar 10, 2019
    Posts:
    4
    HQ FPS weapon assets And STP Template asset integration with emerald 3.0
     
  2. adifrank

    adifrank

    Joined:
    Dec 11, 2017
    Posts:
    26
    Thanks that helped a lot.
     
  3. Tom163

    Tom163

    Joined:
    Nov 30, 2007
    Posts:
    1,290
    A* Pathfinding has been mentioned many times already, but as far as I can see there is no official support for it, yet.

    Does someone have an integration they can share, or at least advise on how to go about creating one?
     
    radiantboy likes this.
  4. khushalkhan

    khushalkhan

    Joined:
    Aug 6, 2016
    Posts:
    177
    @BHS an update with the strafing one would have been great, if sound detection is taking time do this one
    Strafing - Allow AI to strafe in circles around their targets within a customizable distance.
     
    radiantboy likes this.
  5. Tom163

    Tom163

    Joined:
    Nov 30, 2007
    Posts:
    1,290
    That was posted 2015. What is the status on A* pathfinding support?
     
  6. jcomouth_de

    jcomouth_de

    Joined:
    Dec 28, 2017
    Posts:
    5
    Hi, how can I setup a taunt sound? So when the AI detects an enemy, he should yell and then run towards the player.
     
  7. GamePowerNetwork

    GamePowerNetwork

    Joined:
    Sep 23, 2012
    Posts:
    257
    Oh wow, I literally just came here to ask about pathfinding since A* is what I just switched to.

    If pathfinding isn't in @BHS could you share how it can be implemented?
     
  8. DromoDesigner

    DromoDesigner

    Joined:
    Mar 27, 2016
    Posts:
    73
    Hello. I have very simple AI for the infantry units in my game, which I use for them to move around when the camera is not showing them. It also calculates the results of combat when they are off camera in a simple way.

    However, when the units are on camera, and the player can see them, I would like a more advanced AI system that would produce interesting and realistic combat. I am thinking of getting Emerald AI for this.

    Is it possible to integrate Emerald AI with my system, so that it only controls units when they are on screen and they can be seen by the player? And as soon as they go off screen, is it possible for my simple AI system to take control of them again?

    Thank you for your advice.
     
  9. julianr

    julianr

    Joined:
    Jun 5, 2014
    Posts:
    1,212
    Looking forward to the sound detection update. I'd imagine it wouldn't take too long to implement. Will it be radius based sound detection where you can define the alert status of each detection based on its distance? So if far away, but inside the radius, the AI will be curious as to where the sound has come from and plays a specific animation, closer sound detection becomes more aware and begins to search for where it was coming from and very close will know where the sound is coming from and seeks out the player or other AI. Or will it just be based on one setting radius with how loud the sound is?
     
  10. Endi24

    Endi24

    Joined:
    May 6, 2015
    Posts:
    50
    Hey, I am looking for a little advice. I am making something very similar to cod zombies (waw, or bo1) where there is one target only (singleplayer) and the zombies follow it relentlessly until the target (player) dies. What I am noticing, is that the way the asset works is more like a detection-range, and If I want the same functionality that I mentioned, I need to increase the detection zone. Issue with that is that the performance tanks as soon as I spawn 40 or so zombies (Ryzen 2 6 cores, 1660TI).
    Clearly this isn't how I should do it. There must be a setting which sets a single target, and the AI should behave aggressively relentless towards it, but it seems I am missing that. Is there a guide that I didn't see about achieving this, or should I stick to fiddling the settings and maybe write custom code for this?
    I need the melee system that the pack offers more than anything, as I can write pathfinding and animation systems myself, so if that can be de-coupled, that would be great. Can it?
     
  11. Amrid

    Amrid

    Joined:
    Apr 7, 2015
    Posts:
    4
    is there any way I coould use combat text on other objects than emerald AI?
    like destructable enviro elements?
    I really like the effect but can't find in docs or in code how it is created on spot, besides the runtime spawned canvas
     
  12. Michael_Berna

    Michael_Berna

    Joined:
    Jul 5, 2019
    Posts:
    39
    I'm having trouble getting the ranged attacks to work. I have an animation assigned to the range with an EmeraldAttackEvent. The enemy is definitely seeing me because it tracks me, and if I change it to melee, it attacks just fine with the melee attacks, but then when I change it to both or range to test the ranged attack, it simply won't trigger it. I'm watching the animator in a second window and it just doesn't want to trigger. Any idea what I may be missing? No errors in the console either.


    upload_2022-5-6_22-28-45.png
    upload_2022-5-6_22-28-56.png
    upload_2022-5-6_22-31-7.png
    upload_2022-5-6_22-33-25.png
    Obstruction ignore has been tested with both nothing and everything and neither seems to help.

    upload_2022-5-6_22-36-0.png
     
  13. Michael_Berna

    Michael_Berna

    Joined:
    Jul 5, 2019
    Posts:
    39
    upload_2022-5-6_22-36-53.png
     
  14. Michael_Berna

    Michael_Berna

    Joined:
    Jul 5, 2019
    Posts:
    39
    I haven't tested this myself, but I believe this API call should do what you want,
    https://github.com/Black-Horizon-Studios/Emerald-AI/wiki/Emerald-AI-API#OverrideCombatTarget
    Code (CSharp):
    1. EventsManager.OverrideCombatTarget(Transform Target);

    Try making a custom function that is triggered by Emerald AI System script -> AI Settings -> Events -> On PlayerDetection Event() that tracks if the player target has been set and if not calls OverrideCombatTarget on each of your AI.
     
    Endi24 likes this.
  15. JanDawid

    JanDawid

    Joined:
    Jul 7, 2014
    Posts:
    283
    [Version 2.0] I have a goat object that just generally wanders around and would like to make it follow the player when they perform a certain action nearby (think of the goat quest in The Witcher 3). However, no matter what I try, the goat continues to keep wandering, or just becomes stationary.
    I have tried setting the waypoint target as the character, changing behaviour type, setting the player relation to Enemy, setting the Follow target, and nothing works.
    The closest thing was the "SetCombatTarget" which got the goat turning towards the player and looping through one of their idle animations, but they did not start moving towards the player.
     
  16. Michael_Berna

    Michael_Berna

    Joined:
    Jul 5, 2019
    Posts:
    39

    Have you checked the goat's detection settings (Detection & Tags -> Tag & Faction -> Detection layers) Make sure that your player is on the same layer that's listed on your detection layers and that it is tagged with the tag "Player"
    Check and make sure that your animations are set properly also. Sometimes if it just stops, it could be because it is missing an animation such as combat run/walk. Also, have you tried making the goat as a pet? That may be better than having it as an enemy. The pet behavior type is designed to follow you but not attack your enemies if that's what you want.
     
  17. magique

    magique

    Joined:
    May 2, 2014
    Posts:
    4,030
    Emerald AI has specific hard-coded requirements to allow changing it into a following companion. If the AI does not meet those requirements then it won't work. Unless it's changed, the AI must be set to Cautious and either Brave or Foolhardy confidence
     
  18. khushalkhan

    khushalkhan

    Joined:
    Aug 6, 2016
    Posts:
    177
    if sound detection is taking long strafing should be done first, AI is still standing in front of player which seems very dumb if it strafe around player in circle it seems very good also hard to attack
     
  19. netaliev97

    netaliev97

    Joined:
    Jan 5, 2020
    Posts:
    8
    hello, tell me how to spread bullets on the enemy
     
  20. JanDawid

    JanDawid

    Joined:
    Jul 7, 2014
    Posts:
    283
    Awesome, this worked! It was due to the detection layer not being set to the same layer as the player.
    Thank you!
     
    Michael_Berna likes this.
  21. Michael_Berna

    Michael_Berna

    Joined:
    Jul 5, 2019
    Posts:
    39

    For future generations, here's what the fix was with the help of Black Horizon Support:
    I used the debug to find out if the AI could "see" my player https://github.com/Black-Horizon-Studios/Emerald-AI/wiki/Enabling-an-AI's-Debug-Tools

    It turns out, the view was occluded. The reason is that the transform of the player was too near the ground. I then applied the target position modifier and got it near the center of the player. https://github.com/Black-Horizon-Studios/Emerald-AI/wiki/Using-the-Target-Position-Modifier

    Next, I changed obstruction ignore layers to nothing.
     
  22. OneManEscapePlan

    OneManEscapePlan

    Joined:
    Oct 14, 2015
    Posts:
    222
    @BHS Projectiles have a "High Quality Collisions" option that turns on Continuous Collision Detection, but this doesn't work because the projectiles use Trigger colliders and Trigger colliders never use CCD.
     
  23. afavar

    afavar

    Joined:
    Jul 17, 2013
    Posts:
    66
    Hello, I am working on a multiplayer game where I am using Emerald AI for enemies. I would like to enable AI scripts only on the host. Clients will only receive position and animation of the AI. I wanted to ask what is the best way to disable an AI at the start and reenable it if we are the host. Would disabling all Emerald AI scripts and enabling them later at the runtime be ok?
     
  24. fahad979

    fahad979

    Joined:
    Dec 11, 2020
    Posts:
    4
    The Hit effect animation of AI doesn't seem to work when AI is walking or running towards target. Any solutions?
     
  25. Alexandus

    Alexandus

    Joined:
    Sep 5, 2012
    Posts:
    25
    @BHS Hi there, is there a general eta for the next update?
     
    iChuy likes this.
  26. a5196

    a5196

    Joined:
    Jun 24, 2021
    Posts:
    1
    Excuse me, I have a question on accessing the combat text system. How can I call the CreateCombatText function in Invector Character Controller?
     
  27. Deleted User

    Deleted User

    Guest

    Has anyone been able to get this to work with the AI Behavior type set to Passive? I don't want the AI attacking all the time, only when provoked. Seems the AI only works with Aggressive behavior .
     
    Last edited by a moderator: May 25, 2022
  28. micuccio

    micuccio

    Joined:
    Jan 26, 2014
    Posts:
    143
    Hi there!
    I have a small issue with the obstruction detection when the AI is using Ranged attack. In particular if the first AI is blocking the view of the second one and this is behind the first, it will not proceed to go close to the Player but will just stand there doing nothing.
    I set the obstructed action to Move closer immediately but it does not really help.
    Any suggestion? I would really like to make the obstructed AI walk around the blocking one and reposition itself.

    Thank you and best regards,

    Dom
     
  29. Fragment1

    Fragment1

    Joined:
    Aug 30, 2013
    Posts:
    67
    Hello, I had a look but can't see anything for this in the forums.
    Is there any way to teleport my AI in a way where it will completely ignore the fact it has just been moved?

    Essentially my world is on a treadmill where if the player gets further than 200m away from the origin they and everything else will get shifted back towards zero.

    Problem is, a wandering AI that gets teleported with navmmeshagent.warp() will not really know where it is. For example, with a 10m wander dynamic distance set, he'll waddle off to the north east and a breakpoint shows 132.8336 remainingDistance in the agent.

    1. Load scene with player at x1024, y128, z1024
    2. First run of the treadmill runs on first frame, moving player to 0,0,0 and everything around him to that + offset.
    3. 5 seconds go by, and the AI decides to wander.
    4. It wanders far longer than the permitted distance, until it hits a wall. It appears to have picked a point on the navmesh from its original position and not its new position that it has now been at for several seconds.

    is there a way I can manually teleport an AI without the player noticing any unusual behaviour given the context?
    Snippet:

    Code (CSharp):
    1.  
    2.     void Update()
    3.     {
    4.         if (hasPath)
    5.         {
    6.             agent.SetDestination(targetPos);
    7.  
    8.             hasPath = false;
    9.         }
    10.     }
    11.  
    12.     bool hasPath = false;
    13.     Vector3 targetPos = Vector3.zero;
    14.  
    15.     public void Move(Vector3 offset)
    16.     {
    17.         if (navmesh)
    18.         {
    19.             hasPath = false;
    20.  
    21.             if (agent.hasPath)
    22.             {
    23.                 hasPath = true;
    24.                 targetPos = agent.pathEndPosition + offset;
    25.             }
    26.  
    27.             agent.Warp(transform.position + offset);
    28.         }
    29.         else
    30.         {
    31.             transform.SetPositionAndRotation(transform.position + offset, transform.rotation);
    32.         }
    33.     }
    34.  
     
    Last edited: Jun 7, 2022
  30. Darrkbeast

    Darrkbeast

    Joined:
    Mar 26, 2013
    Posts:
    125
    Hi, looks like the 'EventsManager.KillAI();' function does not work, causes the AI to try to find target instead. To avoid this I just use damage with high amount, but wanted to call out the bug. Oh using the latest version and unity version 2021.3.0f1.
     
  31. raviel12345

    raviel12345

    Joined:
    May 9, 2021
    Posts:
    4
    hi every one i am getting error with like this cannot covered float into int
    Emerald AI 3.0 and invector
     

    Attached Files:

  32. raviel12345

    raviel12345

    Joined:
    May 9, 2021
    Posts:
    4
    i have an error coming up with invector 2.6.2a
    its say cannot covert float into int
     

    Attached Files:

  33. Ravl

    Ravl

    Joined:
    May 14, 2013
    Posts:
    35
    [Emerald AI 3.0]
    Hello all,
    I am having an issue with Combat Hit Animations. I want that every time the AI is hit to play the Hit Animation but it seems that this is not happening. I assume is somehow 'random'? The problem is that most of the time I kill the AI without triggering the animation.

    Edit: I see the hit animation only appears if the AI is in IDLE mode. If he is running or attacking me will not play. IS there a solution for that?

    I tried to use an event: OnTakeDamage but I don't know what to do there. I cant use 'emotes' because the AI is in combat and emotes cannot be used. I searched the API, hoping to find a 'pause emerald ai feature' and then simply play my animation but there is no feature for that.

    Any idea? Thank you
     
    Last edited: Jun 16, 2022
  34. raviel12345

    raviel12345

    Joined:
    May 9, 2021
    Posts:
    4
    hi i am using invector 2.6.2a having error with integration any help
     
  35. BHS

    BHS

    Joined:
    Dec 21, 2009
    Posts:
    4,762
    How are you calling the KillAI function? It should kill an AI as all it does is deal a high amount of damage. The only way your AI would look for a target is if it had more than 9999999 health. If this is the case, increase 9999999 to something even higher.

    Code (CSharp):
    1. /// <summary>
    2. /// Instantly kills this AI
    3. /// </summary>
    4. public void KillAI()
    5. {
    6.    if (!EmeraldComponent.IsDead)
    7.    {
    8.       EmeraldComponent.Damage(9999999, EmeraldAISystem.TargetType.AI);
    9.    }
    10. }
     
  36. BHS

    BHS

    Joined:
    Dec 21, 2009
    Posts:
    4,762
    I'm currently looking into the Invector issue.
     
  37. BHS

    BHS

    Joined:
    Dec 21, 2009
    Posts:
    4,762
    Emerald AI 3.1.5 is now live!

    This update is important and should resolve any remaining detection issues. Users should also now use the Collider Position Source when using the Target Position Modifier on their character controllers as this will now dynamically adjust in size depending on the character controller's collider height.

    The Target Position Modifier section on the Emerald AI Wiki has been updated with using these new features: https://github.com/Black-Horizon-Studios/Emerald-AI/wiki/Using-the-Target-Position-Modifier

    3.1.5 Release Notes
    Improvements
    • Improved the Target Position Modifier script to allow a character controller's collider to be used for positioning (with still allowing for a height offset). This allows for the hit point to reposition during runtime if a player crouches and the collider changes size.
    • Improved the way line of sight detects targets (both detected and undetected) by using the collider's bounds.
    • Improved some code in the SearchForTarget function.
    • Improved the way the movement blend trees use their movement turning animations so they're more likely to play during movement turns. This is especially noticeable for quadruped models with turning animations.
    • An option called Movement Turning Sensitivity has been added to AI's Settings>Movement>Turning Settings to adjust the above option. A value of 1 was the original amount and the new default is a value of 2.
    Bug Fixes
    • Fixed a bug that could cause some character controllers to not reliably be detected.
    • Fixed a bug that wouldn't properly apply some ranged animations to an AI that was using the Both Weapon Types option.
    • Fixed a bug that could allow an AI to rotate towards non-combat position while playing an Emote Animation.
    • Fixed a bug that caused an error when killing an AI that hadn't yet detected a target.
    • Fixed a bug that allowed a hit effect to spawn on both the default hit position and the impact effect position when using Location Based Damage (This should only be played once from the impact effect position).
     
    Last edited: Jun 17, 2022
    Deckard_89, Bioman75 and julianr like this.
  38. gamestache

    gamestache

    Joined:
    Aug 18, 2017
    Posts:
    2
    Hi!
    Quick question, if I want to stun the enemy, preventing them from attacking and moving, which API calls would i use for this?
    As far as i know for movement it would be the event EventsManager.StopMovement();
    However for the attacking, im not so sure, would it be EventsManager.CancelAttackAnimation(); ?

    Thanks!
     
  39. Ravl

    Ravl

    Joined:
    May 14, 2013
    Posts:
    35
    @BHS any thoughts on this?
     
  40. BHS

    BHS

    Joined:
    Dec 21, 2009
    Posts:
    4,762
    Yes, hit animations will only play when the AI is idling or not moving. This is to prevent an exploit where the player can continuously hit an AI and never allow it to attack. I'm working on finding a solution that allows hit animations to play better while still giving an AI a chance to attack. One solution for now is to just set the AI's Min and Max Attack Speed to 1. This should give the AI a chance to play a hit animation and still attack.
     
  41. Ravl

    Ravl

    Joined:
    May 14, 2013
    Posts:
    35
    Thanks for the reply, I will test the Attack Speed hack.

    Regarding the issue, maybe a solution would be that when the AI is moving/attacking to have a % for showing the hit animation. The dev could set it to 50% so half of the attacks will also result into playing the animation :)
     
  42. Pixelith

    Pixelith

    Joined:
    Jun 24, 2014
    Posts:
    576
    Edit
    I looked through the API and found the general gist of what needs to be done.

    Original

    How would I go about pausing the AI for something like the player throwing an enemy? I want to include special one on one attacks but not too sure how to go about it.
     
    Last edited: Jun 19, 2022
  43. Darrkbeast

    Darrkbeast

    Joined:
    Mar 26, 2013
    Posts:
    125
    Hi having a issue with the emeraldAIEventsManager.ResetAI(); on AI using both melee and ranged. If a stay at a distance and the AI never engages in melee its fine, however if I go in and it switches to melee, the next time its respawns is just targets the player and never attacks. Its like its stuck between those two states. I've not modified the ai, I just call the reset method when it dies.
     
  44. gamestache

    gamestache

    Joined:
    Aug 18, 2017
    Posts:
    2
    If anyone is trying to implement a stun effect, the following worked for me:

    Code (CSharp):
    1.  public void EnemyStun(int stunDuration)
    2.     {
    3.         EventsManager.StopMovement();
    4.         EventsManager.StopFollowing();
    5.         EmeraldComponent.enabled = false;
    6.         emeraldAIDetection.enabled = false;
    7.         StartCoroutine(EndStunEffect(stunDuration));
    8.     }
    9. IEnumerator EndStunEffect(int _stunDuration)
    10.     {
    11.         yield return new WaitForSeconds(_stunDuration);
    12.         if (EmeraldComponent.CurrentHealth <= 0)
    13.         {
    14.             //Enemy dies, so do nothing otherwise you'll get an error.
    15.             yield return null;
    16.         }
    17.         else if (EmeraldComponent.CurrentHealth > 0)
    18.         {
    19.             EmeraldComponent.enabled = true;
    20.             emeraldAIDetection.enabled = true;
    21.             EventsManager.ResumeMovement();
    22.             EventsManager.ResumeFollowing();
    23.         }
    24.     }
    25.  
    I couldnt get any animation to play during the stun. If anyone has any ideas i'd be keen to try!
     
  45. Ravl

    Ravl

    Joined:
    May 14, 2013
    Posts:
    35
    Hi, I think you just can call the gameObject.GetComponent<Animation>().Play("stuntAnim");

    this should do the trick, right?
     
  46. JanDawid

    JanDawid

    Joined:
    Jul 7, 2014
    Posts:
    283
    Is there any general fix for Emerald AI not using all Attack animations assigned to the System component?
    I import an Animation Profile with multiple attack animations, but they only end up using 1 at runtime. I then manually add the attack animations to the list of attack animations under the Animations > Combat tab in the System component, and still, only uses 1 at runtime.
    I even refresh the Animator and can see that it has multiple attack animations assigned to the Animator. If I put in a debug log in EmeraldAICombatManager.cs at line 16 to check the "EmeraldComponent.MeleeAttacks.Count", it always just returns 1.
    Can this be fixed at all?
     
  47. magique

    magique

    Joined:
    May 2, 2014
    Posts:
    4,030
    Did you set up the melee attacks damage settings for each attack?
     
  48. raviel12345

    raviel12345

    Joined:
    May 9, 2021
    Posts:
    4
    i damage the enemy and his not following me
     
  49. Alexandus

    Alexandus

    Joined:
    Sep 5, 2012
    Posts:
    25
    +1, strafing would be an incredible boost to the AI's combat performance
     
    khushalkhan likes this.
  50. netaliev97

    netaliev97

    Joined:
    Jan 5, 2020
    Posts:
    8
    Setting up Ranged Weapon Hand IK
    when I turn on Look at options--IK type--Emerald IK, enemy stops shooting
    when I turn on Look at options--IK type--Unity IK, enemy shooting
    tell me how to fix