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
    Thanks, I'll look into adding something like this with the next update.
     
  2. FrostedBrain

    FrostedBrain

    Joined:
    Sep 26, 2019
    Posts:
    31

    Perfect! That's just what I needed thank you.
     
  3. unity_7UFP4-iCkwsgjg

    unity_7UFP4-iCkwsgjg

    Joined:
    Dec 13, 2017
    Posts:
    323
    now that i got my player damaging my AI my AI is not damaging my player even when hitting it? happened after the update :(
     
    Last edited: Oct 7, 2019
  4. marco-maceratesi

    marco-maceratesi

    Joined:
    Sep 20, 2013
    Posts:
    13
    I'm sorry I forgot to mention the Unity version: 2019.2.8.
    I also attach a video demo to better explain the problem.



    A little help please :(
     
  5. BHS

    BHS

    Joined:
    Dec 21, 2009
    Posts:
    4,760
    You need to ensure that only the FPS Player object has the Player Tag and Player Layer. You also need to make sure no other unneeded layers are using the AI's Detection Layers . If not, Emerald AI will pick them up when it's searching for targets. Do your RFPS's weapon objects have colliders on them?
     
  6. unity_7UFP4-iCkwsgjg

    unity_7UFP4-iCkwsgjg

    Joined:
    Dec 13, 2017
    Posts:
    323
    turns out my cow is taking damage but it still keeps on running how can i fix this? Fixed
     
    Last edited: Oct 8, 2019
  7. combatsheep

    combatsheep

    Joined:
    Jan 30, 2015
    Posts:
    133
    Thank you!:)
     
  8. magique

    magique

    Joined:
    May 2, 2014
    Posts:
    4,030
  9. unity_7UFP4-iCkwsgjg

    unity_7UFP4-iCkwsgjg

    Joined:
    Dec 13, 2017
    Posts:
    323
    does anyone know how to make it so that my player can pull my AI to the ground? like when a lion attacks a zebra?
     
  10. BHS

    BHS

    Joined:
    Dec 21, 2009
    Posts:
    4,760
    Which previous version? I changed the Equip and Unequip function with the 2.3 version to include a string for the weapon type you would like to enable or disable. This is controlled via the String parameter within the Animation Event. These string values are either Melee or Ranged.
     
  11. CDVoss

    CDVoss

    Joined:
    Jun 24, 2019
    Posts:
    10
    Hello BHS -
    I dont know if you would look into it in the future.
    But the obstruction timer doesn´t seem to work anymore on ranged AI. (I dont have any interfering scripts on the AI - So it should work as default).
    Ive set it to 8 seconds in my example - But the ai moves immediately towards the player when encountering an obstruction.
     
  12. magique

    magique

    Joined:
    May 2, 2014
    Posts:
    4,030
    Ahh, I see. I wasn't aware of that. I will see if that helps.

    [EDIT]
    Yes, that works now. Thanks for the new information.
     
    Last edited: Oct 9, 2019
  13. unity_7UFP4-iCkwsgjg

    unity_7UFP4-iCkwsgjg

    Joined:
    Dec 13, 2017
    Posts:
    323
    how can i get my player to give xp ? want different ai to give different amounts
     
  14. magique

    magique

    Joined:
    May 2, 2014
    Posts:
    4,030
    You would have to code this sort of functionality yourself. You could add an OnDeath event handler and point to a script that has OnDeath function. That script could also define the XP value for the AI. And then you just have to apply that XP to wherever you are accumulating it.
     
  15. unity_7UFP4-iCkwsgjg

    unity_7UFP4-iCkwsgjg

    Joined:
    Dec 13, 2017
    Posts:
    323
    i got some code i added onto the emeraldAIPlayerdamage so when it hits ai it gains xp but i don't want every ai to give say 50 xp?
     
  16. magique

    magique

    Joined:
    May 2, 2014
    Posts:
    4,030
    You want XP added for every hit? Not just when the AI dies?
     
  17. magique

    magique

    Joined:
    May 2, 2014
    Posts:
    4,030
    Here is a sample script that adds XP on damaged as well as on death. Simply attach the script to your AI and hook up the OnDamaged and OnDeath events to the appropriate functions. You'll need to add in your own code in place of the TODO items so that the xp values are actually applied to your character.

    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4.  
    5. public class AIHelper : MonoBehaviour
    6. {
    7.     public int xpOnDamaged;
    8.     public int xpOnDeath;
    9.  
    10.     public void OnDamaged()
    11.     {
    12.         // TODO: call my function that adds xpOnDamaged value to player's XP
    13.     }
    14.  
    15.     public void OnDeath()
    16.     {
    17.         // TODO: call my function that adds xpOnDeath value to player's XP
    18.     }
    19. }
    20.  
     
    combatsheep likes this.
  18. unity_7UFP4-iCkwsgjg

    unity_7UFP4-iCkwsgjg

    Joined:
    Dec 13, 2017
    Posts:
    323
    only want xp when ai dies. Like for example pig would give say 20 xp on death but elephant would give 50xp upon death
     
  19. SickaGames1

    SickaGames1

    Joined:
    Jan 15, 2018
    Posts:
    1,269
    Code it... You will feel better about yourself! or you can check out Game Creator and download the add ons.
     
  20. pccross

    pccross

    Joined:
    Jun 20, 2015
    Posts:
    106
    I've just started using Umotion Pro to improve my game animations. Was wondering, are there any tips with using its animations alongside EAI? For instance, if I want a wandering AI to break from his path to perform a custom action (animation), would I need to disable the EAI temporarily, and play the custom animation via script, and then re-enable EAI after?
     
  21. magique

    magique

    Joined:
    May 2, 2014
    Posts:
    4,030
    Then you just need my base script with only one function as follows:

    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4. public class AIHelper : MonoBehaviour
    5. {
    6.     public int xpOnDeath;
    7.     public void OnDeath()
    8.     {
    9.         // TODO: call my function that adds xpOnDeath value to player's XP
    10.     }
    11. }
    When you attach the script to an AI, just set the xp value for that AI. And you'll have to add your own code to actually update the player XP. This example script is really what you should use as the basis for all your AI. Expand on it to handle all your unique AI needs. Put other event handlers in there as needed and hook them up to the Emerald AI event system.
     
  22. unity_7UFP4-iCkwsgjg

    unity_7UFP4-iCkwsgjg

    Joined:
    Dec 13, 2017
    Posts:
    323
    ah right will check this out thank you :) normally when i try add code on death event it stops the ai being damaged
     
  23. magique

    magique

    Joined:
    May 2, 2014
    Posts:
    4,030
    It should work perfectly. This is exactly how I do it. My AI script has the same OnDeath hooked to the OnDeath event and it calls into my GameMaster component to add xp to the player and it works beautifully.
     
  24. unity_7UFP4-iCkwsgjg

    unity_7UFP4-iCkwsgjg

    Joined:
    Dec 13, 2017
    Posts:
    323
    tried that script and added this to my to give xp to my player but not giving xp to player
    Code (CSharp):
    1.         GetComponent<XPGiver>().experience += 100;
    2.  
    .



    this is my xp script for player to gain xp (atm pressing a button gains xp to player) want to change it though so gains only on AI death

    Code (CSharp):
    1.  
    2.         //Variables
    3.  
    4.         public int level;
    5.         public float experience;
    6.         private float experienceRequired;
    7.  
    8.         public float hp;  // FOR TESTING PURPOSES
    9.  
    10.  
    11.  
    12.         //Methods
    13.         private void Start()
    14.         {
    15.             level = 1;
    16.             hp = 100;
    17.             experience = 0;
    18.             experienceRequired = 100;
    19.         }
    20.  
    21.         private void Update()
    22.         {
    23.             Exp();
    24.  
    25.             if(Input.GetKeyDown(KeyCode.E))
    26.             {
    27.                 experience += 100;
    28.             }
    29.         }
    30.  
    31.         void RankUp()
    32.         {
    33.             level += 1;
    34.             experience = 0;
    35.  
    36.             switch (level)
    37.             {
    38.                 case 2:
    39.                     hp = 200;
    40.                     experienceRequired = 200;
    41.                     break;
    42.  
    43.                 case 3:
    44.                     hp = 300;
    45.                     experienceRequired = 300;
    46.                     print("You have hit Level 3");
    47.                     break;
    48.             }
    49.         }
    50.  
    51.         void Exp()
    52.         {
    53.             if (experience >= experienceRequired)
    54.                 RankUp();
    55.         }
    56.     }
    57.  
    58.  
     
  25. magique

    magique

    Joined:
    May 2, 2014
    Posts:
    4,030
    Did you hook up the script's OnDeath function to the AI's Death event?
     
  26. unity_7UFP4-iCkwsgjg

    unity_7UFP4-iCkwsgjg

    Joined:
    Dec 13, 2017
    Posts:
    323
    erm how do i do that ? sorry been a long day
     
  27. magique

    magique

    Joined:
    May 2, 2014
    Posts:
    4,030
    It sounds like you need to spend a little more time with the documentation to get a better grasp of the basics. However, to do this just go to the Emerald AI System script in the Inspector. Select AI's Settings and the Events button. There you will see all the possible events you can hook up. Select Combat and then go down to the Death() event. Click the + button to add a handler. Drag the AI from the hierarchy into the Object slot. Then select the No Function dropdown. Find the name of the script such as AIHelper and then select the function such as OnDeath.

    [EDIT]
    Looks like the docs don't really explain the Events system so sorry for sounding a bit harsh. I thought there was a video tutorial somewhere about it, though. I'll try to find it.
     
    Last edited: Oct 9, 2019
  28. unity_7UFP4-iCkwsgjg

    unity_7UFP4-iCkwsgjg

    Joined:
    Dec 13, 2017
    Posts:
    323
    ah yeah documents are abit lacking. Done this but when i add event in the inspecter emerald ai system my AI wont die . when i remove the event the ai can be killed any ideas?
     
  29. magique

    magique

    Joined:
    May 2, 2014
    Posts:
    4,030
    Something else must be wrong. Adding an event handler won't break anything unless your event handler code itself is messing the AI up. The event is only called when the AI dies and calling the event is only extra code beyond what EmeraldAI is doing. What does your script look like exactly?
     
  30. unity_7UFP4-iCkwsgjg

    unity_7UFP4-iCkwsgjg

    Joined:
    Dec 13, 2017
    Posts:
    323
    this is my xp the ai should give
    Code (CSharp):
    1.  
    2.         public int experienceOnDamaged;
    3.         public int experienceOnDeath;
    4.  
    5.         public void OnDamaged()
    6.         {
    7.             GetComponent<XPGiver>().experience += experienceOnDeath;
    8.          
    9.         }
    10.  
    11.         public void OnDeath()
    12.         {
    13.  
    14.             GetComponent<XPGiver>().experience += experienceOnDeath;
    15.  
    16.        
    17.         }
     
  31. magique

    magique

    Joined:
    May 2, 2014
    Posts:
    4,030
    First, you should reduce your script down to just the following:

    Code (CSharp):
    1.         public int experienceOnDeath;
    2.  
    3.  
    4.         public void OnDeath()
    5.         {
    6.  
    7.             GetComponent<XPGiver>().experience += experienceOnDeath;
    8.  
    9.      
    10.         }
    Since you only want to add XP when the AI dies. Aside from that, I don't see anything wrong with the way you are doing it. Can you take a screenshot of the Inspector window showing how the script is hooked up to the Death event? I can't imagine what could be wrong, but there is no way this code should prevent the AI from dying.

    [EDIT]
    Wait. I think what might be happening is that your GetComponent<XPGiver>() is probably returning null, which would cause the script and your AI to stop functioning properly. Is the XPGiver script on your AI or somewhere else? The way you wrote this assumes it is attached to the AI, which makes no sense to me. It should be a global instance of some sort so that you only need one XPGiver.
     
  32. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,670
    For Dialogue System users, the Dialogue System Extras page has a patch for the integration package to update it for Emerald AI 2.3.0.2.
     
    BHS likes this.
  33. unity_7UFP4-iCkwsgjg

    unity_7UFP4-iCkwsgjg

    Joined:
    Dec 13, 2017
    Posts:
    323
    screen shot of set up and console for a reference issue on script. Player has the xpgiver script and xphelper is for ai
     

    Attached Files:

  34. magique

    magique

    Joined:
    May 2, 2014
    Posts:
    4,030
    As I suspected. Please see my edited comment above for the null reference that I figured was happening.
     
  35. unity_7UFP4-iCkwsgjg

    unity_7UFP4-iCkwsgjg

    Joined:
    Dec 13, 2017
    Posts:
    323
    ah right xp helper is attached to the ai as want a variant depending on which ai my player kills?
     
  36. magique

    magique

    Joined:
    May 2, 2014
    Posts:
    4,030
    XPHelper, yes, but not XPGiver. Where is XPGiver located?
     
  37. unity_7UFP4-iCkwsgjg

    unity_7UFP4-iCkwsgjg

    Joined:
    Dec 13, 2017
    Posts:
    323
    ah its cool done it thanks though you have helped alot :) anyway to make it though so depending on ai level depends on xp gained?
     
  38. magique

    magique

    Joined:
    May 2, 2014
    Posts:
    4,030
    You mean you want different XP amounts for different AI Level? If so, then I assume you are adjusting the AI level field as well as health amount in some dynamic way through code? As is, these fields are static and you would need multiple AI prefabs with different values. And if you have multiple prefabs with different AI level/health then you can just set their XP value differently.

    However, if you are intending to adjust level/health and other parameters dynamically through script then you can simply do the same for the XP values as well. So many different ways to handle this so it all depends on how you are structuring it.

    I'm actually working on creating a single prefab for an AI and dynamically changing the AI parameters after the AI is spawned from a pool. I will then also adjust their XP value based on some formula such as xpValue * level.
     
  39. unity_7UFP4-iCkwsgjg

    unity_7UFP4-iCkwsgjg

    Joined:
    Dec 13, 2017
    Posts:
    323
  40. marco-maceratesi

    marco-maceratesi

    Joined:
    Sep 20, 2013
    Posts:
    13
    I apologize for the delay in the response.
    There are no colliders on weapons, the only thing I didn't mention is that Emerald AI character has the default ragdoll of unity for death (instead of animation...).
     
  41. AndyNeoman

    AndyNeoman

    Joined:
    Sep 28, 2014
    Posts:
    938
    @BHS , ive been posting about my issue trying to get the same effect you have in you lightning strike video on discord and on here (Not sure where my message has gone) but could you provide the sample code you used to change you AI human into the werewolf on the video? I keep getting errors using instantiate and i thought there was api code within emerald/unistorm but i cant find it in the docs.
     
  42. CDVoss

    CDVoss

    Joined:
    Jun 24, 2019
    Posts:
    10
    Still does anyone else here on the forum, have the problem regarding the obstruction timer?
    Ive even tried it on an empty project on the default guardian AI from "Emerald AI". But the obstruction timer doesnt seem to work at all. Neither do the stationary option. The AI moves immediately after the player is out of the view.
    The obstruction timer is a little importnant to me, since i want some NPC´s to be less reactive than others, so they just dont swarm in on the player.
    Hope someone could look into.
    Best regards
    -CDVoss
     
  43. Hawk0077

    Hawk0077

    Joined:
    Nov 6, 2017
    Posts:
    788
    I just got Emerald AI and so have a newby question.

    When setting up the AI In the scene... can I then drag the Animal Object into the Project window and then use that prefab in CRUX?

    Also do I need a navmesh for this to work, as CRUX spawns the animal without but Emerald AI seems to suggest I need to bake a navmash?

    Any advice appreciated, thanks.
     
  44. BHS

    BHS

    Joined:
    Dec 21, 2009
    Posts:
    4,760
    If you would like to play a custom animation, you can assign the animation to the AI's Emote Animations List and play it using the following code with Emote Animation ID:
    Code (CSharp):
    1. EmeraldAIEventsManager EventsManager = GetComponent<EmeraldAIEventsManager>();
    2. EventsManager.PlayEmoteAnimation(int EmoteAnimationID)
    The AI should stop and play the emote animation then continue to its destination.
     
  45. BHS

    BHS

    Joined:
    Dec 21, 2009
    Posts:
    4,760
    I'll take a look at this to make sure everything is working correctly. If not, I'll get it fixed.
     
  46. BHS

    BHS

    Joined:
    Dec 21, 2009
    Posts:
    4,760
    The ragdoll shouldn't affect the AI's detection process as the ragdoll components are disabled on start. Can you try enabling the Debug Tools (located at the end of the Docs tab) to get a better idea of exactly is being detected and/or obstructed? This will allow Emerald AI to debug log the current target as well as any obstructions to the Unity Console.
     
  47. BHS

    BHS

    Joined:
    Dec 21, 2009
    Posts:
    4,760
    Try this and see if it works. Just attach this to an empty gameobject and assign the AI object. It should transform the struck object into the NewAI object.

    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4. using UniStorm;
    5.  
    6. public class SpawnAILightningEvent : MonoBehaviour
    7. {
    8.     public GameObject NewAI;
    9.  
    10.     void Start()
    11.     {
    12.         //Assign an event to UniStorm's Lightning Strike Event
    13.         UniStormSystem.Instance.OnLightningStrikeObjectEvent.AddListener(() => CustomLightningEvent());
    14.     }
    15.  
    16.     void CustomLightningEvent()
    17.     {
    18.         //Make sure an object is currently struck and that it's an Emerald AI agent
    19.         if (UniStormSystem.Instance.LightningStruckObject != null && UniStormSystem.Instance.LightningStruckObject.GetComponent<EmeraldAI.EmeraldAISystem>() != null)
    20.         {
    21.             //Instantiate an new AI in the struck object's place
    22.             GameObject SpawnedAI = Instantiate(NewAI, UniStormSystem.Instance.LightningStruckObject.transform.position, UniStormSystem.Instance.LightningStruckObject.transform.rotation);
    23.  
    24.             //Destroy the struck AI
    25.             Destroy(UniStormSystem.Instance.LightningStruckObject);
    26.         }
    27.     }
    28. }
     

    Attached Files:

    AndyNeoman likes this.
  48. BHS

    BHS

    Joined:
    Dec 21, 2009
    Posts:
    4,760
    Yes, NavMesh is required for Emerald AI agents. You have to use a project based prefab object. A scene object will not work. Are you using Crux 2.0? Crux 2.0 uses Crux Objects, so you need to create these and apply them to Crux. A tutorial on this can be found here:
     
    Hawk0077 likes this.
  49. Hawk0077

    Hawk0077

    Joined:
    Nov 6, 2017
    Posts:
    788
    Yes I'm using Crux 2. It spawns the animals but does'nt perform the animation I set up using Emerald. But I cant get a NavMesh to bake at present and presume thats the reason why they wont animate.

    I already setup an animal using crux as suggested, I went through that video earlier. Thanks
     
  50. Nitrox32

    Nitrox32

    Joined:
    May 9, 2017
    Posts:
    161
    I'm getting this warning after updating to 2.3.0.2

    Parameter 'Weapon Type State' does not exist.
    UnityEngine.Animator:SetInteger(String, Int32)
    EmeraldAI.Utility.EmeraldAIInitializer:InitializeWeaponTypeAnimation() (at Assets/Emerald AI/Scripts/Components/EmeraldAIInitializer.cs:1231)
    EmeraldAI.Utility.EmeraldAIInitializer:Initialize() (at Assets/Emerald AI/Scripts/Components/EmeraldAIInitializer.cs:30)
    EmeraldAI.EmeraldAISystem:Awake() (at Assets/Emerald AI/Scripts/System/EmeraldAISystem.cs:823)