Search Unity

  1. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

[RELEASED] Emerald AI 2.4.1 - The Ultimate Universal AAA Quality AI Solution

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

  1. wendymorrison

    wendymorrison

    Joined:
    Jan 6, 2014
    Posts:
    234
    Hi, I have a problem when you shoot the AI when he doesn't see you he will look at the ground then go straight into attacking even if you go in his line of sight while he is doing this glitch he won't go after you. Please note I am using HFPS Controller which everything else seems to work.
     
  2. FDGSundae

    FDGSundae

    Joined:
    Aug 28, 2019
    Posts:
    7
    Has anyone integrated this into the Corgi Engine? I'm looking for something to replace the existing, minimal/feature-sparse system which comes with that system.
     
  3. wendymorrison

    wendymorrison

    Joined:
    Jan 6, 2014
    Posts:
    234
    I have noticed this only happens on line of sight because I tried trigger and it never happens but I only want line of sight.
     
  4. ewanchurchill

    ewanchurchill

    Joined:
    Oct 10, 2018
    Posts:
    20
    This might seems like a simple question, but can this be used in a 2D project?
     
  5. Marco-Paoloni93

    Marco-Paoloni93

    Joined:
    Nov 22, 2019
    Posts:
    3
    Hi, anyone used thi asset on a Vr Project? The problem is i would like to display the Text Damage but by default the Canvas i setted in Overlay, how can i manage it to make it work also in VR?
     
  6. thaomoua

    thaomoua

    Joined:
    Jun 21, 2015
    Posts:
    4
    I got into a situation and I can't figure out what's wrong.

    Simple setup: two factions (good & bad). 2 good guys (1 solider up front, 1 archer in rear) vs 1 bad guy. When the game starts, the good soldier and bad soldier run toward each other and starts attacking. Somehow the bad guy's attack is being sent to the archer while it stands & attacks the good soldier.

    (the good soldier and bad soldier are copy of same game object, and I just change the faction)
     
  7. Rahd

    Rahd

    Joined:
    May 30, 2014
    Posts:
    323
    duplicating the Ai can cause a lot of problems .
     
  8. tcz8

    tcz8

    Joined:
    Aug 20, 2015
    Posts:
    368
    @BHS I have questions about the new version:

    1. With Emerald, can we add variety to the animations of our AI? The way I usually do it is with sub state machines and a StateMachineBehavior that randomly chose an animation during OnStateMachineEnter (using an anim parameter). But I don't see any way to do this in Emerald beside adding multiple skill entries which in a complex AI can get really crowded.
    2. Is it possible to make a skill that plays an animation that transitions into a custom state?
    3. Are we allowed to modify the state machine? I don't see any other way of making complex systems without it.
    4. With StateMachineBehaviors I could implement a LOT of things that emerald doesn't do by itself but I need to make sure emerald wont overwrite our changes to the state machine, does emerald rebuild/overwrite the state machine? Can it be prevented?
    Some sort of advanced mode were we specify animation parameters and values to set instead of animations would definitely be a kick ass feature for more advanced users. Allowing us to deal with our own state machine would be awesome.
     
    Rahd and Gabriel_SG like this.
  9. fabiobh

    fabiobh

    Joined:
    May 28, 2013
    Posts:
    90
    @BHS The update 2.4.1 supports localized damage?
    I mean, if I hit the enemy in the head, it will give more damage if I hit the enemy in the body.
    Is it possible for a long-range AI enemy to look for cover just like in an FPS game?
     
  10. adifrank

    adifrank

    Joined:
    Dec 11, 2017
    Posts:
    6
    Hi, Is there anyway for AI to detect Player by sound ?

    Like I kill 1st AI but just nearby 2nd AI ignores until I get in range of 2nd AI.
     
    Rahd likes this.
  11. Rahd

    Rahd

    Joined:
    May 30, 2014
    Posts:
    323
    a short answer, if you gonna add a new State that has the same name of the default State of the animator like Movement or combat Movement the Animator profile system will replace the clips inside it based on the order of the tree, or the name of the clip state if there is no blend tree (maybe the order not sure about the single clip state).
    if you want to create a new State with new names sure it will work, but since you have started coding why not code it into the animation profile and the rest of the scripts, it's easy .
    just start adding your clips input into the editor script , then the Ai System script then into the AIInitializer script then , Animation Profile ... etc,
    the reason I chose to do this as well, is : Knowing all of your clips without using Animator.StringToHash GetCurrentAnimatorStateInfo , is a great advantage ! ! . plus it's very organized .and you can Stop States and clips for working altogether if you choose to.


    not sure what do you mean but this gives me a great idea.
    maybe when the player makes loud sounds, physics.overlapsphere will get all the Ai in the radius of that sound and set the player as a target, or maybe set their destination to the sound position like an explosion.
     
  12. MilesSmiles

    MilesSmiles

    Joined:
    Nov 27, 2012
    Posts:
    115
    Hey @BHS I'm trying to setup a random moving object as an "enemy" without using the Emerald AI system on it. I just have a moving cube that when an Emerald AI character collides with the cube, the AI character dies.

    I have DamageAIByCollision script on the cube and the proper tag/layer on both the cube and the AI character but the AI character isn't dying with 1 health point.

    I see it's possible with the boulder hitting the character...just need to know how to set it up.

    Cheers.
     
    Last edited: Aug 13, 2020
  13. gearedgeek

    gearedgeek

    Joined:
    Jun 19, 2015
    Posts:
    182
    I'm getting this error when the player gets in range of the AI. I'm using Opsive UCC 2.2.4 and using the community integration from @magique. The AI is working but throwing up this error.
    Code (CSharp):
    1. NullReferenceException: Object reference not set to an instance of an object
    2. EmeraldAI.Utility.EmeraldAIDetection.DetectTargetType (UnityEngine.Transform Target, System.Nullable`1[T] OverrideFactionRequirement) (at Assets/Emerald AI/Scripts/Components/EmeraldAIDetection.cs:1084)
    3. EmeraldAI.Utility.EmeraldAIDetection.SetDetectedTarget (UnityEngine.Transform DetectedTarget) (at Assets/Emerald AI/Scripts/Components/EmeraldAIDetection.cs:1058)
    4. EmeraldAI.Utility.EmeraldAIDetection.SearchForTarget () (at Assets/Emerald AI/Scripts/Components/EmeraldAIDetection.cs:1008)
    5. EmeraldAI.Utility.EmeraldAIDetection.DetectTarget (UnityEngine.GameObject C) (at Assets/Emerald AI/Scripts/Components/EmeraldAIDetection.cs:343)
    6. EmeraldAI.Utility.EmeraldAIDetection.UpdateAIDetection () (at Assets/Emerald AI/Scripts/Components/EmeraldAIDetection.cs:602)
    7. EmeraldAI.Utility.EmeraldAIDetection.Update () (at Assets/Emerald AI/Scripts/Components/EmeraldAIDetection.cs:59)
    8.  
     
  14. gearedgeek

    gearedgeek

    Joined:
    Jun 19, 2015
    Posts:
    182
    I believe I have fixed this error by deleting the Emerald AI folder in my project and reimported Emerald AI.
     
  15. eddieray7

    eddieray7

    Joined:
    Feb 1, 2019
    Posts:
    7
    I'm trying to create my own companion AI with a model and specific animation for that model. I've entered all of the clips into the Animation pages and created the Emerald .overrideController which is assigned in the slot for the Animator component.

    When I hit play, the character sinks into the terrain to the center of the character, and does nothing.

    I've added the Rigidbody and set up a Box Collider just like the Fallen Guardian sample.

    In the console I get this message constantly:

    IndexOutOfRangeException: Index was outside the bounds of the array.
    EmeraldAI.EmeraldAISystem.Update () (at Assets/Emerald AI/Scripts/System/EmeraldAISystem.cs:1027)

    ... which doesn't make sense because it's trying to load clip info for layer 0 and I can see that the animator controller is set up and populated with all the states and they refer to my clips.

    I'm using the latest EmeraldAI with Unity 2019.3.15.

    Any ideas what I'm forgetting/missing?
     
  16. micuccio

    micuccio

    Joined:
    Jan 26, 2014
    Posts:
    129
    Hi There!
    I've just updated to version 2.4.1 and I do have the following problem.
    The AIs Don't die! their health levels go down to zero or lower but they seem not to die.
    I get the following error:

    EmeraldAI.EmeraldAISystem.Damage (System.Int32 DamageAmount, System.Nullable`1[T] TypeOfTarget, UnityEngine.Transform AttackerTransform, System.Int32 RagdollForce, System.Boolean CriticalHit) (at Assets/Emerald AI/Scripts/System/EmeraldAISystem.cs:2371)
    EmeraldAI.EmeraldAISystem.SendEmeraldDamage () (at Assets/Emerald AI/Scripts/System/EmeraldAISystem.cs:2154)
    EmeraldAI.EmeraldAISystem.EmeraldAttackEvent () (at Assets/Emerald AI/Scripts/System/EmeraldAISystem.cs:2063)


    I use Unity 2018.3 and I cannot find the culprit of it!
    Please help!
    Thanks in advance,




    Dom
     
    Last edited: Aug 17, 2020
  17. Darrkbeast

    Darrkbeast

    Joined:
    Mar 26, 2013
    Posts:
    112
    Hi, my AI is doing the same thing, Ill shoot him for a while and then he will just look strait at the ground and attack nothing. I'm using Top Down Engine. Also it happens in both line of site and trigger
     
  18. eddieray7

    eddieray7

    Joined:
    Feb 1, 2019
    Posts:
    7
    How do I set up Support abilities for a melee attack AI?
     
  19. MilesSmiles

    MilesSmiles

    Joined:
    Nov 27, 2012
    Posts:
    115
    wow ...cricket sound in here for support. :(
     
  20. Darrkbeast

    Darrkbeast

    Joined:
    Mar 26, 2013
    Posts:
    112
    Think I figured my issue out, damage script was giving wrong transform, fixed that and looks to be working.
     
  21. eddieray7

    eddieray7

    Joined:
    Feb 1, 2019
    Posts:
    7
    It appears that ResetAI() doesn't seem to result in a working AI when used to respawn a dead AI. The respawn AI will start moving and then just stop doing anything.
     
    Rahd likes this.
  22. Eldurin

    Eldurin

    Joined:
    Dec 10, 2017
    Posts:
    19
    The sinking part can be caused by an animation mismatch. For example, when the walking animation is set to a Humanoid Rig and the model is set to a Generic Rig under Import Settings for the model or animation.
     
  23. unity_7UFP4-iCkwsgjg

    unity_7UFP4-iCkwsgjg

    Joined:
    Dec 13, 2017
    Posts:
    316
    anyone having this were factions are able to be changed with SetFactionLevel. My ai changes factions when using this from example neutral or aggressive with setfactionlevel and are already set on aggressive, but they carry on acting as if they are neutral to each other?
     
    SickaGamer likes this.
  24. walter_sung

    walter_sung

    Joined:
    Jun 13, 2016
    Posts:
    15
    @BHS is it possible for an AI to change faction? Like 'convert' to another faction and then inherit the faction relations?
     
  25. Rahd

    Rahd

    Joined:
    May 30, 2014
    Posts:
    323
    never did test this !!
    yeah had this issue as well it has to do with the scriptable object of a faction, I recreated a new one and it worked.
    i hope it does for you too .
     
  26. agent_Macgyver

    agent_Macgyver

    Joined:
    Sep 1, 2012
    Posts:
    26
    I am having difficulty with calling "play emote animation' into the OnStart Event area.

    firstly, there doesn't see to be a way to control the emote animation speed, even though the documentation says the speed can be modified.

    secondly, if I call the "play emote animation" on a melee AI, and the AI enters a state of combat while the animation is still playing, the AI will be able to attack once, but then is not able to move. It just stands there and rotates in place.

    Am I skipping a step? I understand that play emote can't be used in combat, but sometimes I can't control when the emote plays and combat starts. It seems that if the emote is playing AND combat begins, the AI will stop the emote, but then freeze in place after the first attack.

    At this time, I can put the AI's state to Passive, play the emote, and then change the state to something else, but I am not sure this is ultimately a good way to do it. I would prefer that I just call the emote and if in combat, it just doesn't work.
     
    Last edited: Aug 24, 2020
  27. longshotsg

    longshotsg

    Joined:
    Dec 8, 2014
    Posts:
    9
    Hi,

    Thought I tried asking it here first.
    How exactly does the "Emerald Unity Tag" works?
    Based on the guide, it's the Unity tag for the game object.

    Emerald Unity Tag
    The Unity Tag used to define other Emerald AI objects. This is the tag that was created using Unity's Tag pulldown at the top of the gameobject.

    But what does "other Emerald AI objects" mean here?
    Does every unit that uses Emerald AI has to be in the same Unity tag since there is only one selected option for the dropdown?

    Using the "AI vs AI" example scene as a reference,
    It uses "Respawn" Unity tag and "Water" layer.
    If i change it to my Unity tag such as Enemy or Friendly in this field under "Tag and faction options", where enemy(kobold) has the enemy tag and a friendly ai(fallen guardian) has the friendly tag, they will practically ignore each other.

    So how exactly does this work?
    Thanks.
    I'm using 2.4.1 with Unity 2019.3.5f
     
  28. Syllvia

    Syllvia

    Joined:
    Mar 26, 2013
    Posts:
    16
    @Rahd

    You mentioned awhile back that you adapted the running attack to use unity Match Targeting. There's not much good documentation on actual implimentions of that, would you be able to go over exactly what you did? Either for our own edits, or just how to utilize match targeting in general, cuz there's just no info out there over this important seeming thing.
     
  29. Rahd

    Rahd

    Joined:
    May 30, 2014
    Posts:
    323
    i used it for jumping to match the feet bones to the surface I want to jump on, and on the run attack animation to match the root of the rig to the player position, so the Ai will adjust its path when the player change position mid-attack.
    it worked with humanoid rigs, I later drop it, and replaced the jump with 3 types of generic animations small mid big
    and depending on the distance of the jump the Ai will use one of the 3 jump clips .
    for the run attack, it was too overpowered , so the gameplay was very hard . i removed it and kept the code for later uses like climb ...humanoid rigs for etc . used the match targeting with StateMachineBehaviour scripts
     
  30. wood333

    wood333

    Joined:
    May 9, 2015
    Posts:
    697
    Does this mean that the Invector integration video is no longer current?

    EDIT: With the latest version of Emerald and Shooter, and after following the Invector integration. Emerald ai npcs can damage the Invector Player, BUT the Player cannot damage an AI npc created by the latest version of Emerald. Both melee and range by the Invector Player do not damage an Emerald AI.

    SOLVED: I recommend you add to your ai setup instructions to resize the collider.
     
    Last edited: Sep 10, 2020
  31. danteswap

    danteswap

    Joined:
    Oct 27, 2013
    Posts:
    152
    hi there i am new to emrald ai , I want to build some herds of animals where other animals will follow the leader and if player attack the leader or any follower then all of the animals should attack the player, Is there any tutorial on these if yes can you please provide a link to that
     
  32. Rahd

    Rahd

    Joined:
    May 30, 2014
    Posts:
    323

    depending on how many animals you will need to create a flocking system
    other than that a communication system will do what you need.
    i can't recall any tuto , but you can start with the events provided on emerald ai, like onAttacked , or onDeath , etc
    example OnAttacked you can tell your communication script will send a message to all the animals to alert them ,or to tell them the attacker position , or to tell some that one of the animals is attacked so they would heal him . lol.. etc ...
    then start creating other events and the pet logic on the behavior script is a great source for following the animal leader.
     
  33. danteswap

    danteswap

    Joined:
    Oct 27, 2013
    Posts:
    152
    Thanks For The Help I will Try To Implement this . Really appreciate for your time.
     
  34. uz986

    uz986

    Joined:
    Oct 29, 2017
    Posts:
    10
    Hello there,

    It is great AI and everything is working really great.

    but I am facing really annoying issue which I am unable to fix at all.
    Sometime when the AI walking towards the player then it kind of floats above the ground for few seconds and whole character mesh act weird, (Collider and Navmesh agent all is basically remain on the ground, but only the rig goes up). After extreme testing what I have found that when sometime AI spots the player then both Walk animation and Run animation have threshold value at 1 and they tend to run at the same time, which causes wierd animation visual.

    Now first I want to say, both walk and run animation for the model is same. and this problem last from 1 second to 3 or 4 second and happens randomly but if It happens and I intermediately make the threshold value 0 for one animation, then it issue get resolved, now I am not sure where in the code this issue is coming from.

    I hope someone can help me solve this.


    Edit: I set the Movement type to "Root Animation" and and for now I did not encounter the bug again, hopefully I think its fix now
     
    Last edited: Sep 10, 2020
  35. micuccio

    micuccio

    Joined:
    Jan 26, 2014
    Posts:
    129
    Hi There.
    I am encountering some issues using the Weapon type: Both.
    If I check the main Emerald script seems that the attack distance of the Melee is set to the Ranged one and therefore the AI simply stands there.
    I have no idea how to fix this issue.

    Any suggestions?

    Thanks in advance,

    Dom
     
  36. uz986

    uz986

    Joined:
    Oct 29, 2017
    Posts:
    10
    Well I am not really expert, I could be wrong.

    However I did not find any option for changing the distance, I believe it use same distance for both. As for attacking I think if the it give damge accurately when range attack animation is done then it should attack from that distance as well with melee animation.

    Make sure to check your animations are put there correctly, and event function is added in the animation
     
  37. MilesSmiles

    MilesSmiles

    Joined:
    Nov 27, 2012
    Posts:
    115
    Hi,

    I'm getting the following error on a new project, fresh install of Emerald:

    "skeleton_swordsman_allinone's Attack 1 is missing a EmeraldAttackEvent Animation Event. Please add one or see Emerald AI's Documentation for a guide on how to do so."

    The skeleton will move and not fall through the ground but I get this error. If I use an Synty polygon character I get the same error and he wont move and falls through the ground.

    I havent had to setup an attack event before but now it seems I do. What should I do here?

    Cheers.
     
  38. SickaGamer

    SickaGamer

    Joined:
    Jan 15, 2018
    Posts:
    1,004
    When is 2.5 out?
     
  39. BHS

    BHS

    Joined:
    Dec 21, 2009
    Posts:
    4,264
    1) Emerald AI supports up 6 animations for melee attack and 6 animations for ranged attacks. Each of these has an option to choose how attack animations are picked. These options include odds, order, and random.

    2) Yes, if you open the Attack States or Attack States (Ranged) sub-states you can see the transitions to each of the Attack States. Here, you can add additional states that will transition from each attack state, but you will need to add the animations and any additional conditions manually.

    3) The Animator Controller need its state names to remain the same or Emerald AI's Animator Controller Generator will error while trying to find the necessary sates to apply animation to. As long as you don't change the state names, you should be able to add additional states and transitions to existing states.

    4) I don't believe Emerald AI overrides anything. It only adds animations to the preexisting states according to their state name. It is all based off of the "Emerald Animator Controller" within the Resource folder. Modifying this Animator Controller would allow any newly created AI to have a copy of the same Animator Controller, including the additions you've made to it.

    I will certainly have to look into a more advanced mode as you've mentioned. I haven't looked into what's possible with Unity's API in awhile so there may be more features I can add.
     
    tcz8 likes this.
  40. BHS

    BHS

    Joined:
    Dec 21, 2009
    Posts:
    4,264
    This is an upcoming feature I have planned for version 2.4.2.
     
  41. BHS

    BHS

    Joined:
    Dec 21, 2009
    Posts:
    4,264
    This is because you need a Rigidbody Component on your cube in order for collision detection to work correctly.


    The included skeleton should have all needed Attack Events applied.

    The error message says exactly what to do, here's the documentation it's mentioning this: https://github.com/Black-Horizon-Studios/Emerald-AI/wiki/Creating-Attack-Animation-Events

    If your AI is ever falling through the floor, it's because you are missing an animation within your AI's animation list. You can press the Check for Missing Animations button and it will tell you which animation is missing.
     
  42. BHS

    BHS

    Joined:
    Dec 21, 2009
    Posts:
    4,264
    Add this function to the EmeraldAIEventsManager script and you will be able to change an AI's faction:

    Code (CSharp):
    1.  
    2. /// <summary>
    3. /// Changes the AI's current faction to the FactionName paramter.
    4. /// </summary>
    5. public void ChangeFaction (string FactionName)
    6. {
    7.    EmeraldAIFactionData FactionData = Resources.Load("Faction Data") as EmeraldAIFactionData;
    8.    EmeraldComonent.CurrentFaction = FactionData.FactionNameList.IndexOf(FactionName);
    9. }
    You can access an AI's API as explained here: https://github.com/Black-Horizon-Studios/Emerald-AI/wiki/Emerald-AI-API#getting-started

    You would call the above function like this (assuming you followed the API guide above):

    Code (CSharp):
    1. EventsManager.ChangeFaction("Thief");
    Setting the specified faction level can be done with the included API. This is explained here: https://github.com/Black-Horizon-Studios/Emerald-AI/wiki/Emerald-AI-API#setfactionlevel
     
    walter_sung likes this.
  43. BHS

    BHS

    Joined:
    Dec 21, 2009
    Posts:
    4,264
    What version of Emerald AI are you using? There should be two separate distances for melee and ranged attacks:
    MeleeAttackDistance.png
    RangedAttackDistance.png
     
  44. micuccio

    micuccio

    Joined:
    Jan 26, 2014
    Posts:
    129
    Hi Thanks for replying.

    I am using the 2.4.1

    I checked the animator for the AI and looks like it does not exit the ranged / melee mode in the relation to the distance. sometimes it works, mostly not. here are my settings:

    ranged_settings_1.PNG Melee_settings_1.PNG


    thanks a lot for the interest,

    Dom
     
  45. Isukoh

    Isukoh

    Joined:
    Apr 2, 2019
    Posts:
    1
    Hello BHS, is bodypart damage implemented yet, or headshot damage?

    If not, what would be the best way to implement this for Emerald AI?
     
  46. SickaGamer

    SickaGamer

    Joined:
    Jan 15, 2018
    Posts:
    1,004
    That is supposed to be done on 2.5... he hasn't mentioned when exactly that is.
     
  47. walter_sung

    walter_sung

    Joined:
    Jun 13, 2016
    Posts:
    15
    Excellent, thank you!
     
  48. wwg

    wwg

    Joined:
    Apr 2, 2014
    Posts:
    123
    @BHS - I've been using Crux and Emerald since they first came out and they are really great!! I'm working with Photon lately, and would really like to use both Emerald and Crux to spawn and sync AI. Have you had any more thoughts about networking support (Photon)? Even if it was a separate add-on, I'd happily pay for it. Thanks!
     
  49. MilesSmiles

    MilesSmiles

    Joined:
    Nov 27, 2012
    Posts:
    115
    Hi,

    Wondering if someone can help me with the DamageAI on collision script for rocks killing the AI. I just want to modify the code so that there's certain force from the rock necessary before it damages the AI. By default the rock just kills the AI when it touches it but I'd like a rigidbody force number...


    namespace EmeraldAI.Example
    {
    /// <summary>
    /// A script that damages AI based on collisions. Can be used for dynamic damaging objects such as rocks, logs,
    /// and other falling objects or collision based weapons.
    /// </summary>
    public class DamageAIByCollision : MonoBehaviour
    {
    public int DamageAmount = 10;


    private void OnCollisionEnter(Collision collision)
    {
    //Damages an AI to the collided object
    if (collision.gameObject.GetComponent<EmeraldAI.EmeraldAISystem>() != null)
    {
    collision.gameObject.GetComponent<EmeraldAI.EmeraldAISystem>().Damage(DamageAmount, EmeraldAI.EmeraldAISystem.TargetType.Player, transform, 200);
    }
    }
    }
    }

     
  50. Nitrox32

    Nitrox32

    Joined:
    May 9, 2017
    Posts:
    136
    I'm having an issue with an AI applying damage to an Invector character after a scene change. When I am going from one scene to the next the Invector player persists. The AI in the first scene works perfectly however after going into the next scene the AI will detect and attack the player as it should. The attack is registering on the Invector player it's just that no damage if being applied to the player. I posted this on discord and what was suggested was to turn off the EmeraldAInitializer before going to the next scene. That didn't seem to help. Any other thoughts?
     
unityunity