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

    AGregori

    Joined:
    Dec 11, 2014
    Posts:
    527
    Getting this error all the time:

    NullReferenceException: Object reference not set to an instance of an object
    Emerald_AI.OnTriggerExit (UnityEngine.Collider C) (at Assets/Emerald AI 2.0/Scripts/System/Emerald_AI.cs:1243)
     
  2. skinwalker

    skinwalker

    Joined:
    Apr 10, 2015
    Posts:
    509
    Merry Christmas!
    I have a question - I have an AI that flees when the player is nearby, but then doesn't return to its starting position once it escaped, I can't find where to set that option.
     
  3. pushingpandas

    pushingpandas

    Joined:
    Jan 12, 2013
    Posts:
    1,419
    Where are the video tutorials? The youtube channel is empty?
     
    AGregori likes this.
  4. pushingpandas

    pushingpandas

    Joined:
    Jan 12, 2013
    Posts:
    1,419
    Is the RFPS tutorial done yet? Cant find it. Thanks
     
  5. llJIMBOBll

    llJIMBOBll

    Joined:
    Aug 23, 2014
    Posts:
    578
    Hi, Update is awesome :D, Just have 1 question, about AI attacking NON Ai objects, like I have setup so I can place some wooden planks to block off doors / windows... but I want the AI to attack them.

    I've added the Layer to the AI, and tried with Use Non-Ai Tag set to true and false but he doesn't seem to want to attack the wooden planks..

    Also in the code i've added
    Code (CSharp):
    1. public void DamageBaseBuilding()
    2.     {
    3.         if (CurrentTarget != null && CurrentTarget.GetComponent<Jims_BuildHealth>() != null){
    4.             CurrentTarget.GetComponent<Jims_BuildHealth>().DoDamage(CurrentDamageAmount);
    5.         }
    6.     }
    And around line 2254
    Code (CSharp):
    1. else if (TargetTypeRef == TargetType.NonAITarget){
    2.                     //Custom code can be added here.
    3.                     DamageBaseBuilding();
    4.                 }
    If you have any Ideas that would be awesome thank you
     
  6. workingman247

    workingman247

    Joined:
    Jul 25, 2015
    Posts:
    11
    When will the Game Kit Controller tutorial be released, or where can I locate it ?
     
  7. zenGarden

    zenGarden

    Joined:
    Mar 30, 2013
    Posts:
    4,538
    Did you added the "NonAITarget" tag to AI "Detection & tags" -> "Total Target Tags" ?
     
  8. AGregori

    AGregori

    Joined:
    Dec 11, 2014
    Posts:
    527
    Console spammed with this NullReference:

    NullReferenceException: Object reference not set to an instance of an object
    Emerald_AI.OnTriggerExit (UnityEngine.Collider C) (at Assets/Emerald AI 2.0/Scripts/System/Emerald_AI.cs:1243)
     
  9. workingman247

    workingman247

    Joined:
    Jul 25, 2015
    Posts:
    11
    I am wish to use Emerald AI to control NPC vehicles....any assistance would be appreciated.
     
  10. BHS

    BHS

    Joined:
    Dec 21, 2009
    Posts:
    4,764
    Hey everyone!

    Sorry for the delay in responding to all your posts. I have been on vacation. :)

    Emerald AI version 2.0.1 is now live which changes the default layers included with Emerald so they used Unity's default tags and layers. It also fixes bugs related to the Cautious Behavior Type as well as a few others.

    I'm currently working on an update to address some of the issues users have posted since version 2.0 has been released. I will get it submitted as soon as possible.

    Interesting, I can use both Pick Target Methods. There must be a conflict somewhere. I'll be sure to pinpoint this and let you, and anyone else using, UFPS, with a solution.


    Invector will come soon. The next tutorial will be RFPS and then Invector. I will try to get these tutorials finished as soon as possible.


    Thanks!

    Yes, you can follow the UFPS integration tutorial here: https://docs.google.com/document/d/...uHce2BVLM3QTq5axg/edit#heading=h.a0xkk77nlkwy


    Now that the holidays are over, I can start fixing the bugs you have posted. I plan on adding better AI positioning soon.


    Strange, those settings should do what you want. This may be related to the UFPS issues you have been having as everything works fine with the default player.



    Strange, usually issues like this are Unity related. I have tested Emerald AI 2.0 with Unity 2017.3 and have not been able to replicate it. I'll be sure to let you know if I can recreate it so I can provide you with a solution to fix it.


    I'll look into this for you. What Behavior Type and Detection Type are you using?


    An AI should automatically return to its starting position after it has escaped its target. It's worth nothing the ReturnToStart function will generate a new waypoint within the AI's starting position according to the AI's Wandering Radius.

    What Flee Type and Wander Type are you using?


    Hey there!

    Right now, I'm focusing on getting the written tutorials done and then I will get started on the video tutorials.


    The RFPS tutorial should be finished the next day or two.


    Hey there,

    Thanks!

    If the Non-AI object has the appropriate tag and layer, the AI should attack or flee from it, given that it has the proper Behavior Type.


    The Game Kit Controller tutorial will be released after Invector, I have lots of controller systems to cover and I'm trying to get the all done as soon as possible. Game Kit Controller will be one of the controllers that will have full integrated support in the near future. I am actively working with the developer.


    Having AI control vehicles would need to be added with a custom script as Emerald AI object control their own model and its animations.
     
    llJIMBOBll and AGregori like this.
  11. skinwalker

    skinwalker

    Joined:
    Apr 10, 2015
    Posts:
    509
    Wander Type is Dynamic
    Confidence : Coward
    Behaviour : Cautious

    When it escapes it just starts walking around, but not moving back.
     
  12. AGregori

    AGregori

    Joined:
    Dec 11, 2014
    Posts:
    527
    Using Passive/Brave/Stationary,
    Trigger/FirstDetected/HighQuality detection.

    I'm using some non-Emerald traffic cars on the scene, and I suspect that Emerald throws the NullReference when it is triggered by these passing (car) rigidbodies.
     
  13. zenGarden

    zenGarden

    Joined:
    Mar 30, 2013
    Posts:
    4,538
    I got many code AI i made about that :
    For example AI calculates uses player position to calculate random destinations at desired positioning (position/front/sides/back) randomly around the player.
    After a number of tries if there is no destination found AI will idle in attack stance or do a raycast from it's position to find a direction that is not blocked to do some little movement.

    I can help you on that if you wish ?
     
  14. unicat

    unicat

    Joined:
    Apr 8, 2012
    Posts:
    425
  15. llJIMBOBll

    llJIMBOBll

    Joined:
    Aug 23, 2014
    Posts:
    578
    It says this is only for Emerald AI Tags, but i've tried with adding it and enabling and disabling the use NON ai... but still no luck, even made a big cube add box collider, set the layer the Building Layer 9, added my damage script and a navmesh obstacle but still it doesn't wanna attack the cube only the player when you go nearer.

    The ai is set to aggressive, and has 3 layers to search for, Player, Building, NPCs...

    There was an update so i'll try if it makes a difference
     
  16. jrackley

    jrackley

    Joined:
    Jan 26, 2017
    Posts:
    55
    Does anyone know of how to get the projectiles to fire more like a machine gun? It seems the projectiles will only fire 1 projectile per attack animation. I have set the Attack animation speeds down as low as .1 and while it does speed things up a little, it is in no way similar to a machine gun firing bullets rapidly. I have looked for something like a fire rate as well and do not see anything for it anywhere.

    I suppose I can write a script to accomplish this but was wandering if I may be overlooking something somewhere to make the fire rate of the projectiles faster.

    It seems as though the ranged part of this update is only really focused along the lines of casting Magic, and not for shooting weapons per say.

    thanks in advance for any advice
     
  17. BHS

    BHS

    Joined:
    Dec 21, 2009
    Posts:
    4,764
    My mistake, I forgot that Coward AI don't return to start as they would most likely run right back at their attacker. However, I can add an option to make fleeing AI return to start.


    Strange, it doesn't look like the non-Emerald tag detection is working properly. I'll find out what's going on and get it working with the next update that I'll be submitting soon. Sorry for any inconveniences this causes you.


    Your offer is appreciated. If you have some code you'd like to recommend, you can send it to Support@BlackHorizonStudios.com :)


    Hey there!

    Try attaching your spawn point to the rig portion of your AI, such as its hand transform. This should allow it to move properly with the model's animations.


    There may be a bug with the Non-AI object detecting. I am currently looking into this and will submit and update as soon as I find out what's going on. Sorry for any inconveniences this causes you.



    Hey there!

    Projectiles can be fired faster by increasing your AI's attack/firing animation speed. Another attack cannot be calculated until the AI's animation has finished playing. Increasing the firing animation should resolve your issue.
     
    llJIMBOBll, AGregori and julianr like this.
  18. jrackley

    jrackley

    Joined:
    Jan 26, 2017
    Posts:
    55
    @BHS Thanks, I will try to speed up the animations, but I swear I tried that too, who knows..too many hours in front of a screen,lol! As for the .1 speed I mentioned, I may have worded that poorly I set the .1 for the min and max times to do attacks after the initial attack.
     
  19. unicat

    unicat

    Joined:
    Apr 8, 2012
    Posts:
    425
    Thank You , works perfect now.
     
  20. uberwiggett

    uberwiggett

    Joined:
    Jun 26, 2015
    Posts:
    105
    Jracklley you might be able to get away with rigging your projectile to be 3 bullets instead of 1(I think you can tag them as only aesthetic), and just setting the overall damage of the 3 so that each attack is a 3 round burst. Of course if you get hit with 1 bullet you get hit with all of them, which might not be what you want in your game.
     
  21. jrackley

    jrackley

    Joined:
    Jan 26, 2017
    Posts:
    55
    Thanks @uberwiggett, good to see you on here! and will try that out as well. We currently have 3 different games going on,lol! Waiting for the Invector Integration, before getting back to the Grigori game, but we needed a break from that one after 12hr days on it for almost 2yrs now!
     
  22. AGregori

    AGregori

    Joined:
    Dec 11, 2014
    Posts:
    527
    Turns out that UFPS-related problems were due to some other asset (Adventure Creator I think) messing up UFPS's hardcoded layer order. UFPS is of course very sensitive about its layers. After reinstalling it, Emerald+UFPS integration is working fine.

    I have a fresh issue with duplicating (override)controllers between several passerby-NPC's in the scene. It doesn't seem to be possible at this time. Is it required to create brand new Emerald controllers for each new NPC?
     
  23. zenGarden

    zenGarden

    Joined:
    Mar 30, 2013
    Posts:
    4,538
    It's not about systems like EQS, but some samples of cheap tricks like those i described above you can you use to have better AI instead of simple Navmesh "go to player".
    I'll post code samples here, there is nothing super advanced of super fancy lol

    For example about melee AI groups, make them idle if they are walking towards the player but they didn't walked a minimum distance during some time intervall.
    Or features like positioning around the character without the navmesh stacking effect with AI behind others moving forward and sliding.

    Each new navigation option you'll add should perhaps be optionnal with a check box, perhaps lot of users like the AI as it is and it's perhaps sufficient for those making some hack n slash for example.
     
    Last edited: Dec 30, 2017
  24. skinwalker

    skinwalker

    Joined:
    Apr 10, 2015
    Posts:
    509
    Can anyone recommend a good way of setting up the navmesh agent for an animal? I have a deer and the navmesh agent looks like a huge circle around it, because of the body shape of the deer. It's also not very good when avoiding the player, you can basically push it if you bump into it.
     
  25. AGregori

    AGregori

    Joined:
    Dec 11, 2014
    Posts:
    527
    Sorted, no longer a problem.
     
  26. jrackley

    jrackley

    Joined:
    Jan 26, 2017
    Posts:
    55
    @skinwalker There are a few ways that could help with your issue. First you could add a Navmesh Obstacle to your player and make it as big as you want to (can be a box or capsule around the player), this will not allow the Animal to come within that distance of you. You can try adjusting the mass in the Rigidbody of the Animal to stop you from being able to push it I believe. As for the Navmesh agent being a big circle around your Animal, that is normal, however you can adjust the size of it to be whatever suits your needs in the settings for the Navmesh agent.

    Hope this helps you some.
     
  27. skinwalker

    skinwalker

    Joined:
    Apr 10, 2015
    Posts:
    509
    My player has a NM obstacle, the problem is that I can push the animal if I bump into it, because the NM Agent tries to stay away from the obstacle, and since I'm moving the player (obstacle) it tries to stay away from it simulating a pushing behaviour. I fixed that on my NPCs by adding a character controller bigger than the NM Agent, but I probably won't be able to do that for the animals.
     
  28. AGregori

    AGregori

    Joined:
    Dec 11, 2014
    Posts:
    527
    Stationary Passive type just loops the 1st idle animation ad infinitum, ignoring the other 2 idle anims. (I'm doing a bartender and he's just looping his pouring drinks anim.) Is this normal or a bug?
     
  29. pushingpandas

    pushingpandas

    Joined:
    Jan 12, 2013
    Posts:
    1,419
  30. pushingpandas

    pushingpandas

    Joined:
    Jan 12, 2013
    Posts:
    1,419
    Example enemy script from vr asset

    //========= Copyright 2017, Sam Tague, All rights reserved. ===================
    //
    // Used on the targets in the example scene. The takaway is the Damage method which
    // is how your Damage method should look like by default to receive damage from
    // VRWeaponInteractor weapons.
    // As an example to show it's working rotates back and then resets when shot
    //
    //=============================================================================
    using UnityEngine;
    using System.Collections;
    namespace VRInteraction
    {
    public class ExampleEnemy : MonoBehaviour {
    public int maxHp = 10;
    public float resetTime = 5;
    public Vector3 upRotation;
    public Vector3 downRotation;
    public Transform forwardTransform;
    private int hp;
    void Start()
    {
    hp = maxHp;
    }
    public void Damage(DamageInfo info)
    {
    if (hp <= 0) return;
    hp -= info.damage;
    if (hp <= 0) Die();
    }
    void Die()
    {
    StartCoroutine(ToggleRotation(true));
    StartCoroutine(Reset(resetTime));
    }
    IEnumerator ToggleRotation(bool fall)
    {
    float t = 0;
    Quaternion startRotation = transform.rotation;
    //Quaternion targetRotation = fall ? Quaternion.Euler(downRotation) : Quaternion.Euler(upRotation);
    Quaternion targetRotation = fall ? Quaternion.LookRotation(forwardTransform.up, -forwardTransform.forward) : Quaternion.LookRotation(forwardTransform.forward, forwardTransform.up);
    while(t<=1)
    {
    if ((fall && hp > 0) || (!fall && hp <= 0)) yield break;
    transform.rotation = Quaternion.Lerp(startRotation, targetRotation, t);
    t += 0.01f;
    yield return null;
    }
    }
    IEnumerator Reset(float seconds)
    {
    yield return new WaitForSeconds(seconds);
    hp = maxHp;
    StartCoroutine(ToggleRotation(false));
    }
    }
    }
     
  31. _invalidusername

    _invalidusername

    Joined:
    Jul 1, 2014
    Posts:
    35
    The update is great, really looking forward to playing with it! One suggestion for something I noticed: you've hardcoded the expected paths ( Assets/Emerald AI 2.0/...) so if the directory structure changes everything breaks. It would be great if this was either configurable or dynamic as a lot of people don't keep third party assets in the root directory
     
  32. BHS

    BHS

    Joined:
    Dec 21, 2009
    Posts:
    4,764
    The animation speed can be set faster by having it set to a higher value such as 10. You can set the min and max Attack Speed to 0 and the Attack Delay to 0 to have the AI attack even quicker. I managed to get the AI attacking pretty fast using these settings.


    I certainly plan on adding further mechanics. Each option of course will be optional for users who want less advanced AI mechanics.



    Great to hear you were able to resolve your issues!


    Hey there!

    It's hard to tell with the code you posted as it's not related to the firing mechanics of the said system. Where your VR controller damages their custom AI, you would use something like:
    Code (CSharp):
    1.  
    2. if (YourVRTarget.GetComponent<Emerald_AI>()){
    3.    YourVRTarget.GetComponent<Emerald_AI>().Damage(damage, Emerald_AI.TargetType.Player);
    4. }
    5.  

    Hey there!

    Thanks, I totally agree. I will be updating this with the next update.
     
  33. AGregori

    AGregori

    Joined:
    Dec 11, 2014
    Posts:
    527
    The NullReference and Stationary animations problem are still bad in 2.0.1. In fact the NullRef often leads to Unity crashing (2017.2.1).

    1.
    NullReferenceException: Object reference not set to an instance of an object
    Emerald_AI.OnTriggerExit (UnityEngine.Collider C) (at Assets/Emerald AI 2.0/Scripts/System/Emerald_AI.cs:1243)


    2.
    Stationary Passive type just loops the 1st idle animation ad infinitum, ignoring the other 2 idle anims. (I'm doing a bartender and he's just looping his pouring drinks anim.) Is this a bug?

    3.
    There's another grazing/idling anim issue with Dynamic Passive types: when AI's have all 3 grazing anims available, they just pick one to replay over and over (even if it's 10+ sec long), only playing the 1st seconds of the other two anims.
     
  34. BHS

    BHS

    Joined:
    Dec 21, 2009
    Posts:
    4,764
    Thanks for the bug reports. I'll get right on fixing them with the update I'm working on.
     
  35. BackwoodsGaming

    BackwoodsGaming

    Joined:
    Jan 2, 2014
    Posts:
    2,229
    So has this now become just another generic AI system? Is all the animal specific stuff now gone? I don't see references to the breeding and herding anywhere now. :(
     
  36. BHS

    BHS

    Joined:
    Dec 21, 2009
    Posts:
    4,764
    Hey Shawn!

    No, Emerald AI simply caters to all kinds of developers. The animal specific features weren't able to make it in at the time of 2.0's release. Animal specific features, such as breeding and herds, are being rewritten/redone and will come with the next update. They are still a top priority. :)
     
  37. BackwoodsGaming

    BackwoodsGaming

    Joined:
    Jan 2, 2014
    Posts:
    2,229
    Cool! Glad to hear it as that stuff was the main reason for my purchasing Emerald. I wont rehash things that have been hashed out in past thread posts already. Just happy to hear that the animal specific stuff didn't hit the chopping block. :)
     
    99thmonkey and BHS like this.
  38. BHS

    BHS

    Joined:
    Dec 21, 2009
    Posts:
    4,764
  39. 99thmonkey

    99thmonkey

    Joined:
    Aug 10, 2012
    Posts:
    525
    I purchased for animal stuff as well.
     
  40. BHS

    BHS

    Joined:
    Dec 21, 2009
    Posts:
    4,764
    The remaining animal features are simply being rewritten and improved just as the other portions of Emerald AI were. The herd mechanics will be a big improvement in comparison to v1 of Emerald AI. I’m currently working on getting them added as soon as possible. :)
     
    uberwiggett likes this.
  41. AGregori

    AGregori

    Joined:
    Dec 11, 2014
    Posts:
    527
    Does Passive Dynamic wander type actually work normally on anyone's project? Whatever I do, the AI never plays any idle anims, and gets stuck in circling itself.
     
  42. skinwalker

    skinwalker

    Joined:
    Apr 10, 2015
    Posts:
    509
    Do you plan to use a state machine instead of having lots of animations inside the animator? (it's almost impossible to add more states that way and see what's going on). For example, I have 80+ animations for each animal and I can only use 15 now.
     
  43. BHS

    BHS

    Joined:
    Dec 21, 2009
    Posts:
    4,764
    It should. I’ll take a look at it today to see what’s going on. If there are any issues, I’ll add the fixes to the update I’m working on.


    I plan on expanding support for more animations with a future update. I’m still deciding how this expanded support will be done. A state machine is certainly a possibility.
     
  44. AGregori

    AGregori

    Joined:
    Dec 11, 2014
    Posts:
    527
    Thanks. To be more precise, Passive Dynamic AI's only play the 1st second of their (2 or 3) grazing animations, then interrupt themselves and wander on. Stationary AI's loop their first idle anim forever, ignoring the other idle anims.
     
  45. pushingpandas

    pushingpandas

    Joined:
    Jan 12, 2013
    Posts:
    1,419
    Tried RFPS implementation. Super smooth! Thanks!
     
  46. BHS

    BHS

    Joined:
    Dec 21, 2009
    Posts:
    4,764
    Thanks for the details. Should be an easy fix.

    You’re welcome! Great to hear the tutorial was easy to follow.
     
  47. Salja

    Salja

    Joined:
    Mar 23, 2017
    Posts:
    353
    BackwoodsGaming likes this.
  48. BHS

    BHS

    Joined:
    Dec 21, 2009
    Posts:
    4,764
    I won’t, the ootii Motion Controller integration tutorial will come right after the Invector 3rd Person Controller tutorial. I was able to get blocking working with RFPS so hopefully the same goes with ootii Motion Controller. :)
     
    BackwoodsGaming and Salja like this.
  49. Salja

    Salja

    Joined:
    Mar 23, 2017
    Posts:
    353
    Thanks yeah ootii blocking is a bit tricky but im 10000000% sure tim will help you on it i cant wait to see the support for it waiting so long time today i buyed crux too
     
    Last edited: Jan 4, 2018
  50. BHS

    BHS

    Joined:
    Dec 21, 2009
    Posts:
    4,764
    Great to hear you purchased Crux! Yes, I’ve been in contact with Tim. If I run into any issues with implementing blocking, I’ll be sure ask him for help.