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

    kuru61

    Joined:
    Oct 17, 2016
    Posts:
    3
    When will Astar-Pathfinding (Aron Granberg) be implemented?
     
    wood333 likes this.
  2. Mafutta

    Mafutta

    Joined:
    Sep 30, 2014
    Posts:
    45
    Any specials instructions for upgrading required? (Other than making a project backup) Looks promising.
     
  3. BHS

    BHS

    Joined:
    Dec 21, 2009
    Posts:
    4,760
    Thanks!

    I haven't had a chance to look into using LoveHate's factions system with Emerald AI so I'm not entirely sure how to go about this at the moment. I do plan on redoing/improving Emerald AI's faction system with the update after 2.3 and I will keep support for LoveHate's faction system in mind when doing so.
     
    Akshara likes this.
  4. BHS

    BHS

    Joined:
    Dec 21, 2009
    Posts:
    4,760
    I plan on looking into support for Astar-Pathfinding, but there are a few portions of Emerald AI I'd like to improve before doing so.
     
  5. BHS

    BHS

    Joined:
    Dec 21, 2009
    Posts:
    4,760
    The 2.3 update shouldn't require removing the system from projects before updating. However, users will need to re-create their Animator Controllers so they can be updated and redo their AI's projectiles using the spells and abilities system.
     
    SickaGames1 likes this.
  6. SickaGames1

    SickaGames1

    Joined:
    Jan 15, 2018
    Posts:
    1,268
    Wahoo! Thanks @BHS! The long awaited for 2.3 :) Did you ever decide if you were going to do the new Flyer AI asset?
     
    Last edited: Jul 29, 2019
  7. Mafutta

    Mafutta

    Joined:
    Sep 30, 2014
    Posts:
    45
    I see. So does all animations and speed settings for each character have to be re-applied manually as well?
    I also use Crux. Any issues with Crux during upgrade ie Do I have to re-make crux objects? Thanks.
     
  8. SickaGames1

    SickaGames1

    Joined:
    Jan 15, 2018
    Posts:
    1,268
    @BHS How hard would it be to add some type of Lua type code (think Tony's dialogue system) to make AI do a series of abilities based on health and or fight time? Basically you could have a fight mechanics section that would do a set of animations and/or scripted abilities based on a logical Lua script.
     
    Last edited: Jul 30, 2019
  9. FractalCore

    FractalCore

    Joined:
    May 15, 2009
    Posts:
    151
    I only just noticed this.

    Awesome. Works perfectly again. Thanks for that. :)
     
    BHS likes this.
  10. Nitrox32

    Nitrox32

    Joined:
    May 9, 2017
    Posts:
    161
    Is there a way to incorporate text mesh to the UI elements?
     
  11. Nitrox32

    Nitrox32

    Joined:
    May 9, 2017
    Posts:
    161
    I'm all of a sudden getting this repeating error when I add UI Elements:
    NullReferenceException: Object reference not set to an instance of an object
    EmeraldAI.Utility.EmeraldAIHealthBar.Update () (at Assets/Emerald AI/Scripts/UI/EmeraldAIHealthBar.cs:56)

    Th UI Displays however it is rotated 180 degrees.
     
    Last edited: Jul 31, 2019
  12. Nitrox32

    Nitrox32

    Joined:
    May 9, 2017
    Posts:
    161
    Sorry for the ton of questions but I'm really enjoying Emerald AI. Here's another:

    The AI Warrior's Hit Effect has been modified, but not updated. To update, go to the AI's Settings tab under the Combat section, in its Emerald Editor, and press the 'Update Hit Effect' button.
    UnityEngine.Debug:Log(Object)
    EmeraldAI.Utility.EmeraldAIInitializer:CheckEditorUpdateButtons() (at Assets/Emerald AI/Scripts/Components/EmeraldAIInitializer.cs:68)
    EmeraldAI.Utility.EmeraldAIInitializer:Initialize() (at Assets/Emerald AI/Scripts/Components/EmeraldAIInitializer.cs:26)
    EmeraldAI.EmeraldAISystem:Awake() (at Assets/Emerald AI/Scripts/System/EmeraldAISystem.cs:773)

    What is this and I can't seem to find the "Update Hit Effect" button.
     
    SickaGames1 likes this.
  13. BHS

    BHS

    Joined:
    Dec 21, 2009
    Posts:
    4,760
    You're welcome!

    Yes and I will finish it when I have the time. :)
     
  14. BHS

    BHS

    Joined:
    Dec 21, 2009
    Posts:
    4,760
    No, not all of them. The new animation system works by splitting melee animations and ranged animations into two different categories. So all ranged animations will need to be reapplied, as well as ranged animation speed settings, because they're being added with the 2.3 version. Crux object should be fine and Crux will work better because I fixed a bug that didn't allow AI to reset properly.
     
  15. BHS

    BHS

    Joined:
    Dec 21, 2009
    Posts:
    4,760
    Emerald AI's combat text system uses text mesh. Other than that, all of the built-in UI systems use the newer UI method. You can certainly create a custom system that uses text mesh though.

    Make sure you have your camera's Tag set to MainCamera. I will be fixing this with version 2.3.

    No worries!

    Press the Update button at the bottom of the Hit Effect tab found under AI's Settings>Combat>Hit Effect. This will be improved with version 2.3 by using Scriptable Objects.
     
  16. Nitrox32

    Nitrox32

    Joined:
    May 9, 2017
    Posts:
    161
    Thanks for your responses. That answers the first round of questions. The Update button wasn't visible because I was experimenting with the Hit Effects and left the field blank despite clearly saying "This field cannot be left blank".:rolleyes:
     
  17. Nitrox32

    Nitrox32

    Joined:
    May 9, 2017
    Posts:
    161
    So here are my next questions. I am using Opsive TPC and have made Emerald AI and TPC work together (many thanks to Magique for the clear and updated code). I'm having trouble with being able to avoid the AI by simply walking though it. I know the solution should be simple like mismatched collider tags or layers. But when I start messing with the layers or tags the hits stop registering or the AI stops responding. Question 1: How do I get the colliders to work without effecting the AI?

    Question 2: I have duplicated the my AI agent and both work fine except the second agent, who is using the same animation as the original one is getting the following error:

    'Warrior (1)' AnimationEvent 'ExecuteEvent' has no receiver! Are you missing a component?

    Why is this?
     
  18. magique

    magique

    Joined:
    May 2, 2014
    Posts:
    4,030
    For this you are probably using an animation that already has its own animation event. I had that issue when I was using animations from Sword & Shield Animset Pro. You can just change the name of the event to SendEmeraldDamage or delete the event if it's not needed.
     
    SickaGames1 likes this.
  19. huntersteeger

    huntersteeger

    Joined:
    Dec 27, 2017
    Posts:
    19
    I could use some help setting up EAI with Unistorm. I am trying to get my AI to have daily activities at certain times using emote animations and such.
     
  20. wigglypuffs

    wigglypuffs

    Joined:
    Aug 10, 2015
    Posts:
    67
    Has 2.3 been submitted for review to the Unity store yet?
     
  21. SickaGames1

    SickaGames1

    Joined:
    Jan 15, 2018
    Posts:
    1,268
    Usually @BHS says when it has. I would venture to say no right now. It should be live soon... Sometimes little things do come up.

    @BHS
    How hard would it be to add some type of Lua type code (think Tony's dialogue system) to make AI do a series of abilities based on health and or fight time? Basically you could have a fight mechanics section that would do a set of animations and/or scripted abilities based on a logical Lua script.
     
  22. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,670
    That's probably outside the scope of where BHS wants to take Emerald AI. But it's certainly possible to use the Dialogue System's Lua and its Emerald AI integration's Lua functions to add this on top of Emerald AI yourself to make your AI do scripted sequences of actions.

    For example, you could hook up Emerald AI's DamageEvent() to call a Dialogue System Trigger that barks "Now I'm angry! Time to draw my big weapon!" and uses a Lua function to enable a special weapon. I'll add some more Lua functions to allow you to check more information about the Emerald AI in the next update.

    That said, a "detected another entity" event would be a handy addition to Emerald AI. Similar to the OnStartCombatEvent() but that gets triggered before combat starts, at the point when the AI first detects something else.
     
  23. BHS

    BHS

    Joined:
    Dec 21, 2009
    Posts:
    4,760
    Sure thing! This is how I would code a schedule system. It uses idle animations and the OverrideIdleAnimation function to allow you to control which animation is played while the AI is in its current time of day activity. It also allow you to set a destination for morning, day, evening, and night each with the ability to set the Wandering Type to Stationary or Dynamic. I plan on expanding this with built-in API the 2.4 update, but this should give you, and others, an example of how to accomplish this.

    I've created 2 systems; one for UniStorm and a general one for users who want to update the time of day with their own custom system.

    How to use - Just attach it to your AI you would like to have a schedule and assign a transform for each time of day location.

    UniStorm Time of Day Schedules:
    Code (CSharp):
    1.  
    2. using System.Collections;
    3. using System.Collections.Generic;
    4. using UnityEngine;
    5. using EmeraldAI;
    6. using UniStorm;
    7.  
    8. public class UniStormAISchedule : MonoBehaviour
    9. {
    10.     public WanderType MorningWanderType = WanderType.Stationary;
    11.     public Transform MorningLocation;
    12.     public int IdleAnimationMorning = 1; //Idle animations are 1 through 3
    13.  
    14.     public WanderType DayWanderType = WanderType.Dynamic;
    15.     public Transform DayLocation;
    16.     public int IdleAnimationDay = 1; //Idle animations are 1 through 3
    17.  
    18.     public WanderType EveningWanderType = WanderType.Stationary;
    19.     public Transform EveningLocation;
    20.     public int IdleAnimationEvening = 1; //Idle animations are 1 through 3
    21.  
    22.     public WanderType NightWanderType = WanderType.Stationary;
    23.     public Transform NightLocation;
    24.     public int IdleAnimationNight = 1; //Idle animations are 1 through 3
    25.  
    26.     public enum WanderType { Dynamic = 0, Stationary = 3 };
    27.  
    28.     public CurrentScheduleEneum CurrentSchedule = CurrentScheduleEneum.Morning;
    29.     public enum CurrentScheduleEneum { Morning = 0, Day = 1, Evening = 2, Night = 3 };
    30.  
    31.     EmeraldAISystem m_EmeraldAISystem;
    32.     EmeraldAIEventsManager m_EmeraldAIEventsManager;
    33.  
    34.     void Start ()
    35.     {
    36.         m_EmeraldAISystem = GetComponent<EmeraldAISystem>();
    37.         m_EmeraldAIEventsManager = GetComponent<EmeraldAIEventsManager>();
    38.         InvokeRepeating("UpdateAISchedule", 0.1f, 1);
    39.     }
    40.  
    41.     void UpdateAISchedule ()
    42.     {
    43.         if (!m_EmeraldAISystem.IsDead)
    44.         {
    45.             if (CurrentSchedule != CurrentScheduleEneum.Morning && UniStormSystem.Instance.CurrentTimeOfDay == UniStormSystem.CurrentTimeOfDayEnum.Morning)
    46.             {
    47.                 m_EmeraldAIEventsManager.ChangeWanderType((EmeraldAISystem.WanderType)MorningWanderType); //Set our AI's Wandering Type for this time of day
    48.                 m_EmeraldAISystem.m_NavMeshAgent.ResetPath(); //Reset our path so the previous destination doesn't interfere with the new one
    49.                 m_EmeraldAIEventsManager.SetDestination(MorningLocation); //Set our destination for this time of day
    50.                 m_EmeraldAISystem.StartingDestination = MorningLocation.position; //Set our dynamic wandering destination for this time of day
    51.                 m_EmeraldAIEventsManager.OverrideIdleAnimation(IdleAnimationMorning - 1); //Set our Idle Animation Index for this time of day
    52.                 m_EmeraldAISystem.WaitTime = 2; //Dynamic - Set our Wait Time to 2 so the AI starts its animation 2 seconds after arrive to its new destination
    53.                 m_EmeraldAISystem.StationaryIdleSeconds = 2; //Stationary - Set our Wait Time to 2 so the AI starts its animation 2 seconds after arrive to its new destination
    54.                 CurrentSchedule = CurrentScheduleEneum.Morning; //Update our current time of day so this only updates once
    55.             }
    56.             else if (CurrentSchedule != CurrentScheduleEneum.Day && UniStormSystem.Instance.CurrentTimeOfDay == UniStormSystem.CurrentTimeOfDayEnum.Day)
    57.             {
    58.                 m_EmeraldAIEventsManager.ChangeWanderType((EmeraldAISystem.WanderType)DayWanderType);
    59.                 m_EmeraldAISystem.m_NavMeshAgent.ResetPath();
    60.                 m_EmeraldAIEventsManager.SetDestination(DayLocation);
    61.                 m_EmeraldAISystem.StartingDestination = DayLocation.position;              
    62.                 m_EmeraldAIEventsManager.OverrideIdleAnimation(IdleAnimationDay);
    63.                 m_EmeraldAISystem.WaitTime = 2;
    64.                 m_EmeraldAISystem.StationaryIdleSeconds = 2;                        
    65.                 CurrentSchedule = CurrentScheduleEneum.Day;
    66.             }
    67.             else if (CurrentSchedule != CurrentScheduleEneum.Evening && UniStormSystem.Instance.CurrentTimeOfDay == UniStormSystem.CurrentTimeOfDayEnum.Evening)
    68.             {
    69.                 m_EmeraldAIEventsManager.ChangeWanderType((EmeraldAISystem.WanderType)EveningWanderType);
    70.                 m_EmeraldAISystem.m_NavMeshAgent.ResetPath();
    71.                 m_EmeraldAIEventsManager.SetDestination(EveningLocation);
    72.                 m_EmeraldAISystem.StartingDestination = EveningLocation.position;
    73.                 m_EmeraldAIEventsManager.OverrideIdleAnimation(IdleAnimationEvening);
    74.                 m_EmeraldAISystem.WaitTime = 2;
    75.                 m_EmeraldAISystem.StationaryIdleSeconds = 2;
    76.                 CurrentSchedule = CurrentScheduleEneum.Evening;
    77.             }
    78.             else if (CurrentSchedule != CurrentScheduleEneum.Night && UniStormSystem.Instance.CurrentTimeOfDay == UniStormSystem.CurrentTimeOfDayEnum.Night)
    79.             {
    80.                 m_EmeraldAIEventsManager.ChangeWanderType((EmeraldAISystem.WanderType)NightWanderType);
    81.                 m_EmeraldAISystem.m_NavMeshAgent.ResetPath();
    82.                 m_EmeraldAIEventsManager.SetDestination(NightLocation);
    83.                 m_EmeraldAISystem.StartingDestination = NightLocation.position;
    84.                 m_EmeraldAIEventsManager.OverrideIdleAnimation(IdleAnimationNight);
    85.                 m_EmeraldAISystem.WaitTime = 2;
    86.                 m_EmeraldAISystem.StationaryIdleSeconds = 2;
    87.                 CurrentSchedule = CurrentScheduleEneum.Night;
    88.             }
    89.         }
    90.     }
    91. }
    92.  
    93.  

    General Time of Day Schedules:
    Code (CSharp):
    1.  
    2. using System.Collections;
    3. using System.Collections.Generic;
    4. using UnityEngine;
    5. using EmeraldAI;
    6.  
    7. public class AISchedule : MonoBehaviour
    8. {
    9.     public WanderType MorningWanderType = WanderType.Stationary;
    10.     public Transform MorningLocation;
    11.     public int IdleAnimationMorning = 1; //Idle animations are 1 through 3
    12.  
    13.     public WanderType DayWanderType = WanderType.Dynamic;
    14.     public Transform DayLocation;
    15.     public int IdleAnimationDay = 1; //Idle animations are 1 through 3
    16.  
    17.     public WanderType EveningWanderType = WanderType.Stationary;
    18.     public Transform EveningLocation;
    19.     public int IdleAnimationEvening = 1; //Idle animations are 1 through 3
    20.  
    21.     public WanderType NightWanderType = WanderType.Stationary;
    22.     public Transform NightLocation;
    23.     public int IdleAnimationNight = 1; //Idle animations are 1 through 3
    24.  
    25.     public enum WanderType { Dynamic = 0, Stationary = 2 };
    26.  
    27.     public CurrentScheduleEneum CurrentSchedule = CurrentScheduleEneum.Morning;
    28.     public enum CurrentScheduleEneum { Morning = 0, Day = 1, Evening = 2, Night = 3 };
    29.  
    30.     EmeraldAISystem m_EmeraldAISystem;
    31.     EmeraldAIEventsManager m_EmeraldAIEventsManager;
    32.  
    33.     void Start ()
    34.     {
    35.         m_EmeraldAISystem = GetComponent<EmeraldAISystem>();
    36.         m_EmeraldAIEventsManager = GetComponent<EmeraldAIEventsManager>();
    37.         InvokeRepeating("UpdateAISchedule", 0.1f, 1);
    38.     }
    39.  
    40.     void UpdateAISchedule ()
    41.     {
    42.         if (!m_EmeraldAISystem.IsDead)
    43.         {
    44.             if (CurrentSchedule == CurrentScheduleEneum.Morning && m_EmeraldAISystem.StartingDestination.x != MorningLocation.position.x)
    45.             {
    46.                 m_EmeraldAIEventsManager.ChangeWanderType((EmeraldAISystem.WanderType)MorningWanderType); //Set our AI's Wandering Type for this time of day
    47.                 m_EmeraldAISystem.m_NavMeshAgent.ResetPath(); //Reset our path so the previous destination doesn't interfere with the new one
    48.                 m_EmeraldAIEventsManager.SetDestination(MorningLocation); //Set our destination for this time of day
    49.                 m_EmeraldAISystem.StartingDestination = MorningLocation.position; //Set our dynamic wandering destination for this time of day
    50.                 m_EmeraldAIEventsManager.OverrideIdleAnimation(IdleAnimationMorning); //Set our Idle Animation Index for this time of day
    51.                 m_EmeraldAISystem.WaitTime = 2; //Dynamic - Set our Wait Time to 2 so the AI starts its animation 2 seconds after arrive to its new destination
    52.                 m_EmeraldAISystem.StationaryIdleSeconds = 2; //Stationary - Set our Wait Time to 2 so the AI starts its animation 2 seconds after arrive to its new destination
    53.             }
    54.             else if (CurrentSchedule == CurrentScheduleEneum.Day && m_EmeraldAISystem.StartingDestination.x != DayLocation.position.x)
    55.             {
    56.                 m_EmeraldAIEventsManager.ChangeWanderType((EmeraldAISystem.WanderType)DayWanderType);
    57.                 m_EmeraldAISystem.m_NavMeshAgent.ResetPath();
    58.                 m_EmeraldAIEventsManager.SetDestination(DayLocation);
    59.                 m_EmeraldAISystem.StartingDestination = DayLocation.position;            
    60.                 m_EmeraldAIEventsManager.OverrideIdleAnimation(IdleAnimationDay);
    61.                 m_EmeraldAISystem.WaitTime = 2;
    62.                 m_EmeraldAISystem.StationaryIdleSeconds = 2;
    63.             }
    64.             else if (CurrentSchedule == CurrentScheduleEneum.Evening && m_EmeraldAISystem.StartingDestination.x != EveningLocation.position.x)
    65.             {
    66.                 m_EmeraldAIEventsManager.ChangeWanderType((EmeraldAISystem.WanderType)EveningWanderType);
    67.                 m_EmeraldAISystem.m_NavMeshAgent.ResetPath();
    68.                 m_EmeraldAIEventsManager.SetDestination(EveningLocation);
    69.                 m_EmeraldAISystem.StartingDestination = EveningLocation.position;
    70.                 m_EmeraldAIEventsManager.OverrideIdleAnimation(IdleAnimationEvening);
    71.                 m_EmeraldAISystem.WaitTime = 2;
    72.                 m_EmeraldAISystem.StationaryIdleSeconds = 2;
    73.             }
    74.             else if (CurrentSchedule == CurrentScheduleEneum.Night && m_EmeraldAISystem.StartingDestination.x != NightLocation.position.x)
    75.             {
    76.                 m_EmeraldAIEventsManager.ChangeWanderType((EmeraldAISystem.WanderType)NightWanderType);
    77.                 m_EmeraldAISystem.m_NavMeshAgent.ResetPath();
    78.                 m_EmeraldAIEventsManager.SetDestination(NightLocation);
    79.                 m_EmeraldAISystem.StartingDestination = NightLocation.position;
    80.                 m_EmeraldAIEventsManager.OverrideIdleAnimation(IdleAnimationNight);
    81.                 m_EmeraldAISystem.WaitTime = 2;
    82.                 m_EmeraldAISystem.StationaryIdleSeconds = 2;
    83.             }
    84.         }
    85.     }
    86. }
    87.  
    88.  
     

    Attached Files:

    Last edited: Sep 19, 2019
    closetgeekshow and huntersteeger like this.
  24. BHS

    BHS

    Joined:
    Dec 21, 2009
    Posts:
    4,760
    Not yet. I'm still working on it, but it's really close. I'll announcer here when I've submitted it. :)
     
  25. BHS

    BHS

    Joined:
    Dec 21, 2009
    Posts:
    4,760
    I'm already working on adding this to the upcoming version 2.3. It could offer some really cool functionality.
     
  26. chrisk

    chrisk

    Joined:
    Jan 23, 2009
    Posts:
    704
    Hi, are you aware of GPU Instancer that support skinned animation?
    https://www.assetstore.unity3d.com/en/?stay#!/content/145114|

    Looking at their API, it doesn't seem that complicated (assuming that it uses Animator) I would love to see the integration and we can probably have massive AI.

    If you haven't looked at it, please check it out and let us know what you think.
    Thanks.
     
  27. BHS

    BHS

    Joined:
    Dec 21, 2009
    Posts:
    4,760
    Hey there,

    I haven't yet seen GPU Instancer. It looks very interesting and could possibly benefit Emerald AI. I will reach out to the developer to see if proper support could be added after the 2.3 update.
     
    chrisk and SickaGames1 like this.
  28. SickaGames1

    SickaGames1

    Joined:
    Jan 15, 2018
    Posts:
    1,268
    @BHS How is 2.3 going? Any ETA?
     
  29. chrisk

    chrisk

    Joined:
    Jan 23, 2009
    Posts:
    704
    Awesome! It might be a good idea to ECS'fy the agent after the integration, then we can have swarm of AI agents in a single scene. ^^
    Cheers!
     
  30. wood333

    wood333

    Joined:
    May 9, 2015
    Posts:
    851
    I was working on my project, and looking at the health bar and AI name, and I was thinking wouldn't it be nice if the color could change with the combat status, for instance color green for non-combat, and red, during combat. How about that?
     
  31. SickaGames1

    SickaGames1

    Joined:
    Jan 15, 2018
    Posts:
    1,268
    Kind of like WoW. Make it so Will!
     
    BHS likes this.
  32. BHS

    BHS

    Joined:
    Dec 21, 2009
    Posts:
    4,760
    Great, I'm doing a lot of testing and quality checking to ensure everything is functioning as it should as it is a pretty complex update. I've also improved quite a few animation blending sections such as blocking, turning, and switching between ranged and melee combat.

    I've also just finished the new target detection system so AI no longer use a trigger collider. The new system only searches for the appropriate layers and offers a huge performance boost for users with lots of colliders in their scenes. This had to be done as the performance boost was important. I was able to get 200+ fps with over 50 AI on screen and all active. This also doesn't require any alterations to an AI on the user's end either.

    As for ETA, I'm fairly confident I can submit the 2.3 update within within the next two weeks.

    I will have a playable demo ready within the next day or two so users who are interested can try out 2.3 and some of its new features and many improvements.
     
    Last edited: Aug 14, 2019
    K4rha, SickaGames1 and magique like this.
  33. BHS

    BHS

    Joined:
    Dec 21, 2009
    Posts:
    4,760
    I can certainly look into ECS. :)
     
  34. BHS

    BHS

    Joined:
    Dec 21, 2009
    Posts:
    4,760
    That's a great idea. I will definitely add this to a future update.
     
  35. SickaGames1

    SickaGames1

    Joined:
    Jan 15, 2018
    Posts:
    1,268
    Yeah. You can keep it the way it is now and make it Non-combat color and In-Combat color! That would be a minor but really nice to have feature!
     
  36. unity_7UFP4-iCkwsgjg

    unity_7UFP4-iCkwsgjg

    Joined:
    Dec 13, 2017
    Posts:
    323
    Is it possible to create a trigger so that your AI will stop wandering to drink water from a river with this asset ?
     
  37. BHS

    BHS

    Joined:
    Dec 21, 2009
    Posts:
    4,760
    I totally agree! :)
     
  38. BHS

    BHS

    Joined:
    Dec 21, 2009
    Posts:
    4,760
    Yes, this can be done using the following code. To use it, just attach it to an object with a collider set to Is Trigger and the AI will stop and play its emote animation when it collides with said collider.

    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4. using EmeraldAI;
    5.  
    6. public class AIDrinkWater : MonoBehaviour
    7. {
    8.     void OnTriggerEnter(Collider collider)
    9.     {
    10.         if (collider.GetComponent<EmeraldAISystem>() != null)
    11.         {
    12.             //Get a reference to the Emerald AI system that was collided with
    13.             EmeraldAISystem m_EmeraldAISystem = collider.GetComponent<EmeraldAISystem>();
    14.  
    15.             //Plays an AI's emote animation according to the Animation ID which for this example is 1.
    16.             m_EmeraldAISystem.EmeraldEventsManagerComponent.PlayEmoteAnimation(1);
    17.         }
    18.     }
    19. }
     

    Attached Files:

    Akshara likes this.
  39. unity_7UFP4-iCkwsgjg

    unity_7UFP4-iCkwsgjg

    Joined:
    Dec 13, 2017
    Posts:
    323
    ah right is that only for the new emerald?
     
  40. RemitPrime

    RemitPrime

    Joined:
    Apr 20, 2016
    Posts:
    23
    Are there any updates for Mirror networking or uSurvival integration?
     
  41. BHS

    BHS

    Joined:
    Dec 21, 2009
    Posts:
    4,760
    New as in the current version 2.2, yes.
     
  42. unity_7UFP4-iCkwsgjg

    unity_7UFP4-iCkwsgjg

    Joined:
    Dec 13, 2017
    Posts:
    323
    ah right, so you can add to separate triggers one for eating grass and another for water?
     
  43. BHS

    BHS

    Joined:
    Dec 21, 2009
    Posts:
    4,760
    I will get to these as soon as the 2.3 version has been submitted which should be in two weeks.
     
    RemitPrime and SickaGames1 like this.
  44. BHS

    BHS

    Joined:
    Dec 21, 2009
    Posts:
    4,760
    That is correct. If you want more than 1 animation to be used, simply replace the 1 with a variable that allows you to customize the number used like below. This will allow you to use different animation for each object. Currently, a total of 3 emote animations can be used.

    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4. using EmeraldAI;
    5. public class AIActionWater : MonoBehaviour
    6. {
    7.     public int AnimationID = 1;
    8.  
    9.     void OnTriggerEnter(Collider collider)
    10.     {
    11.         if (collider.GetComponent<EmeraldAISystem>() != null)
    12.         {
    13.             //Get a reference to the Emerald AI system that was collided with
    14.             EmeraldAISystem m_EmeraldAISystem = collider.GetComponent<EmeraldAISystem>();
    15.             //Plays an AI's emote animation according to the Animation ID which for this example is 1.
    16.             m_EmeraldAISystem.EmeraldEventsManagerComponent.PlayEmoteAnimation(AnimationID);
    17.         }
    18.     }
    19. }
     
    Last edited: Aug 16, 2019
  45. unity_7UFP4-iCkwsgjg

    unity_7UFP4-iCkwsgjg

    Joined:
    Dec 13, 2017
    Posts:
    323
    ah right so i would need to use a water tag for water and a food tag for food both with a default layer?
     
  46. BHS

    BHS

    Joined:
    Dec 21, 2009
    Posts:
    4,760
    You don’t need to actually use tags or layers. You just need to use the emote animation ID where the AnimationIndex variable is (I probably should have called the variable name AnimationID so let’s call it that) :).

    When you’re in the emote animation tab, you have a list of animations each with an ID to identify them. If your water animation has an ID of 1 then you would use 1 for the AnimationID in the script I provided and if your eating animation ID is 2 then you would use 2 for the AnimationID.

    When your AI hits the collider, it will play the emote animation according to the AnimationID within the script that is read from the AI and its emote animation list.
     
  47. unity_7UFP4-iCkwsgjg

    unity_7UFP4-iCkwsgjg

    Joined:
    Dec 13, 2017
    Posts:
    323
    ah brilliant and can we add particles to the emotes like water dripping when it drinks ?
     
  48. BHS

    BHS

    Joined:
    Dec 21, 2009
    Posts:
    4,760
    Yes, there's built-in API that can be used through Animation Events and your AI's emote animations. You can also play sound effects using Animation Events. I'll put together some tutorials to better explain this.
     
  49. BHS

    BHS

    Joined:
    Dec 21, 2009
    Posts:
    4,760
    hessex and Akshara like this.
  50. unity_7UFP4-iCkwsgjg

    unity_7UFP4-iCkwsgjg

    Joined:
    Dec 13, 2017
    Posts:
    323
    thank you for the swift response and apologies for all the questions just want to make sure it covers everything i need. I just need to check if this asset can allow or has the following:

    herding (like for example a herd of zebra)?
    natural behaviors for example zebras grooming each other (interactions)?
    will there be more emotes in the future releases?
    If I add a collider to the water will my animals still be able to swim as well as drink?
    Can a way point be intercepted and carry on if it collides with a plan to eat?
    pack (like for example a pack of lions hunting)?
    Would the character controller provided work on an animal?
    Needs (Is their the ability to provide needs to animals)?

    once again sorry for all the questions :)