Search Unity

  1. Calling all beginners! Join the FPS Beginners Mods Challenge until December 13.
    Dismiss Notice
  2. It's Cyber Week at the Asset Store!
    Dismiss Notice

[ON SALE - 50% OFF!] Emerald AI 2.3 - The Ultimate Universal AAA Quality AI Solution

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

  1. unity_7UFP4-iCkwsgjg

    unity_7UFP4-iCkwsgjg

    Joined:
    Dec 13, 2017
    Posts:
    285
    @ magique i did it finally :) needed to get rid of that last script i placed :)
     
    magique likes this.
  2. zKici

    zKici

    Joined:
    Feb 12, 2014
    Posts:
    223
    Followed the Ability and other documents on your drive

    I have an ability with an ability effect prefab - fire arrow

    In AI settings Combat Damage Settings Ranged,

    Ranged attack transform I added an empty prefab in the NPC where the fire arrow should spawn from.

    There is an offensive animation set and offensive ability the one with the fire arrow.

    However, even though the animation for casting this plays out, the fire arrow is never spawned,

    Am I missing something?
     
  3. unity_7UFP4-iCkwsgjg

    unity_7UFP4-iCkwsgjg

    Joined:
    Dec 13, 2017
    Posts:
    285
    Does emerald ai only allow the player to cause damage with raycasting?
     
  4. Al-

    Al-

    Joined:
    Jun 5, 2015
    Posts:
    24
    It's working now. Thanks!
     
  5. BHS

    BHS

    Joined:
    Dec 21, 2009
    Posts:
    4,045
    That looks about how I would go about it, but instead of using Instantiate, I would initially spawn all AI with:
    Code (CSharp):
    1. EmeraldAIObjectPool.Spawn(GameObject, Transform, Quaternion);
    Then disable all of them when going to the next scene and re-enable them as needed. AI are automatically reset when disabled and re-enabled. I hope this helps.
     
  6. BHS

    BHS

    Joined:
    Dec 21, 2009
    Posts:
    4,045
    Sometimes the transition time from one animation to the next interfere with the Animation Events (this is a known Unity bug). What you can do to make sure Animation Events are being called consistently, is make sure they are not in the transition range of the animation. This can be seen by viewing the AI's animation transitions to the Death state.

    I'll try to get the stop combat event added with the next update.
     
    Deckard_89 likes this.
  7. BHS

    BHS

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

    I haven't had the chance to look into multiplayer support, but I plan on it soon. Another user was able to add support by following these steps which they provided. It's for UNET, but I'm sure the process will be similar: https://forum.unity.com/threads/rel...ality-ai-solution.336521/page-76#post-4920905
     
  8. BHS

    BHS

    Joined:
    Dec 21, 2009
    Posts:
    4,045
    Not currently. Emerald AI uses Unity's NavMesh. However, I do plan on looking into other options, such as A* Pathfinding Pro, soon.
     
  9. unity_7UFP4-iCkwsgjg

    unity_7UFP4-iCkwsgjg

    Joined:
    Dec 13, 2017
    Posts:
    285
    i've asked this question already a while ago when i first started using emerald but i can't for the life of me find the question and answers to it. How can i stop my ai colliding into each other when attacking each other ? ( both ai have colliders attached with istrigger checked).
     
  10. zKici

    zKici

    Joined:
    Feb 12, 2014
    Posts:
    223
    @BHS not sure if my posts are invisible
     
  11. magique

    magique

    Joined:
    May 2, 2014
    Posts:
    3,676
    You mean you don't want them to be able to walk through each other?

    If so, I think there are two possible approaches. I haven't tried either of these so these are just unproven ideas.

    One would be to add a child collider to each AI and set them to a Layer that only collides with the same layer. For example, create a new Layer called AICollider and make sure in your Physics matrix that AICollider layer only collides with AICollider layer.

    Another would be to attach NaMeshObstacle to each AI. This might prevent them from being able to navigate into the other AI's space. I would prefer this approach myself if it works.
     
  12. magique

    magique

    Joined:
    May 2, 2014
    Posts:
    3,676
    Nope, not invisible. Maybe he just missed it or hasn't gotten to it yet. I would help you myself, but I haven't yet tried the feature you are using yet so have no knowledge on it.
     
  13. unity_7UFP4-iCkwsgjg

    unity_7UFP4-iCkwsgjg

    Joined:
    Dec 13, 2017
    Posts:
    285
    ah adding extra colliders don't seem to enable when i press play :( they seem to just keep running when they are meant to attack so not even attacking or causing each other damage :( not sure why ? i'll test the NavMesh0bstacle see if that makes a difference :) trying to get two cows to butt heads had it working before the update but now its not :(
     
  14. magique

    magique

    Joined:
    May 2, 2014
    Posts:
    3,676
    Are they extra colliders on the root of the AI or a child game object? I can try this out myself in a little bit and see if I can get either working.
     
  15. unity_7UFP4-iCkwsgjg

    unity_7UFP4-iCkwsgjg

    Joined:
    Dec 13, 2017
    Posts:
    285
    add the navobstable and they just run around in circles crazy lol . I have a box collider on the top of the head covering whole of head and face :)
     
  16. magique

    magique

    Joined:
    May 2, 2014
    Posts:
    3,676
    Oh, now I recall that the system disables extra colliders even if you add them. So that's a no go.

    So, let me try to understand what you want exactly. You are trying to get 2 AI to collide with each other, but not go through each other? So that you can have 2 rams butt heads? I was just thinking you wanted them to avoid contact. But you want them to contact each other, but then have some sort of reaction when they do?
     
    unity_7UFP4-iCkwsgjg likes this.
  17. unity_7UFP4-iCkwsgjg

    unity_7UFP4-iCkwsgjg

    Joined:
    Dec 13, 2017
    Posts:
    285
    yeah like exactly like that :)
     
  18. Deckard_89

    Deckard_89

    Joined:
    Feb 4, 2016
    Posts:
    205
    Yeah, Emerald automatically disables extra colliders when play begins. It's going to be altered in a future version, also the option to receive damage via separate colliders will be added.
     
  19. magique

    magique

    Joined:
    May 2, 2014
    Posts:
    3,676
    OK, I think I have a possible solution. I'll try it out and let you know.
     
  20. unity_7UFP4-iCkwsgjg

    unity_7UFP4-iCkwsgjg

    Joined:
    Dec 13, 2017
    Posts:
    285
  21. magique

    magique

    Joined:
    May 2, 2014
    Posts:
    3,676
    OK, so the first part is to get around the issue with EmeraldAI disabling our extra colliders. Attach the following script to your AI with the head colliders and add those colliders into the Colliders list for this script.

    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4.  
    5. public class EnableColliders : MonoBehaviour
    6. {
    7.  
    8.     [SerializeField]
    9.     private List<Collider> _colliders = new List<Collider>();
    10.  
    11.     // Use this for initialization
    12.     void Start()
    13.     {
    14.         StartCoroutine(DelayedEnableColliders());
    15.     }
    16.  
    17.     IEnumerator DelayedEnableColliders()
    18.     {
    19.         yield return null;
    20.  
    21.         for (int i = 0; i < _colliders.Count; ++i)
    22.         {
    23.             _colliders[i].enabled = true;
    24.         } // for i
    25.     }
    26. }
    This waits one frame and then enables any colliders you have put in the list. So they will be functional again after EmeraldAI disables them.

    This might be all you need. However, to allow some sort of reaction when the colliders hit, I will post another script shortly. If you already have that part then you won't need it.
     
  22. unity_7UFP4-iCkwsgjg

    unity_7UFP4-iCkwsgjg

    Joined:
    Dec 13, 2017
    Posts:
    285
    ah cool thank you i don't have the reactions only what emerald al provides but my cows don't seem to damage each other either ( followed the steps tags and factions are set up ) not sure whats going on ?
     
  23. magique

    magique

    Joined:
    May 2, 2014
    Posts:
    3,676
    You mean when they butt heads there is no damage? Yeah, that would be expected since that is something extra we are adding on top of the AI itself. Emerald doesn't have any concept of collision damage.

    Are they colliding though at least? If so, I will get you the next part shortly.
     
  24. zKici

    zKici

    Joined:
    Feb 12, 2014
    Posts:
    223
    Well, perhaps. Its just that I've seen responses to posts after mine (and this is the 2nd time me reposting it)

    Thats all,

    Thanks
     
  25. unity_7UFP4-iCkwsgjg

    unity_7UFP4-iCkwsgjg

    Joined:
    Dec 13, 2017
    Posts:
    285
    ah right but before the update they were able to kill each other. Unfortunately not they are way to close to display attack animation :( here is a screenshot :)
     

    Attached Files:

  26. magique

    magique

    Joined:
    May 2, 2014
    Posts:
    3,676
    Is the butting heads animation an attack in EmeraldAI? If so then that should cause damage of some sort when they hit. Change the head colliders to the same layer as the root AI and make the colliders triggers. That might fix it.
     
  27. unity_7UFP4-iCkwsgjg

    unity_7UFP4-iCkwsgjg

    Joined:
    Dec 13, 2017
    Posts:
    285
    added a better view basically the attack is like a stomp then low head and then raise and nope still getting this issue (screenshot)
     

    Attached Files:

  28. magique

    magique

    Joined:
    May 2, 2014
    Posts:
    3,676
    Make head colliders same layer as Root AI and don't make them triggers. I notice that the main AI collider isn't a trigger either so it's worth a try. I don't really have an equivalent AI with that sort of attack so it's hard to test.
     
  29. unity_7UFP4-iCkwsgjg

    unity_7UFP4-iCkwsgjg

    Joined:
    Dec 13, 2017
    Posts:
    285
    tried didn't work :( they still go through each other
     
  30. magique

    magique

    Joined:
    May 2, 2014
    Posts:
    3,676
    Yeah, I'm analyzing it now and the reason is because Emerald changes the Rigidbody of the AI to Kinematic and this prevents any child colliders from getting OnCollisionEnter events. So, the system is working against us here. I'm trying to figure out a way around it.
     
  31. unity_7UFP4-iCkwsgjg

    unity_7UFP4-iCkwsgjg

    Joined:
    Dec 13, 2017
    Posts:
    285
  32. burkenater14

    burkenater14

    Joined:
    Sep 4, 2019
    Posts:
    2
    This Can be done
     
  33. unity_7UFP4-iCkwsgjg

    unity_7UFP4-iCkwsgjg

    Joined:
    Dec 13, 2017
    Posts:
    285
  34. magique

    magique

    Joined:
    May 2, 2014
    Posts:
    3,676
    Try this. Use this modified script:

    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4.  
    5. public class EnableColliders : MonoBehaviour
    6. {
    7.  
    8.     [SerializeField]
    9.     private List<Collider> _colliders = new List<Collider>();
    10.  
    11.     // Use this for initialization
    12.     void Start()
    13.     {
    14.         StartCoroutine(DelayedEnableColliders());
    15.     }
    16.  
    17.     IEnumerator DelayedEnableColliders()
    18.     {
    19.         yield return null;
    20.  
    21.         GetComponent<Rigidbody>().isKinematic = false;
    22.         for (int i = 0; i < _colliders.Count; ++i)
    23.         {
    24.             _colliders[i].enabled = true;
    25.         } // for i
    26.     }
    27. }
    28.  
    Also, change the RigidBody on each AI so that all rotations are frozen and position is frozen. See if it is able to trigger the damage on the attack now.

    Note: I don't know what side effects might come from changing RigidBody to non-kinematic. Although it seems to be working fine from my limited testing.

    [EDIT]
    In this new test, make sure the head colliders are not triggers. And put them on their own Layer so they only collide with each other as before.
     
    Last edited: Oct 21, 2019
  35. unity_7UFP4-iCkwsgjg

    unity_7UFP4-iCkwsgjg

    Joined:
    Dec 13, 2017
    Posts:
    285
    ah working much better thank you but they don't perform their attack animation where they lower their head any ideas? :)
     
  36. magique

    magique

    Joined:
    May 2, 2014
    Posts:
    3,676
    Were they performing the animation before adding this new script and colliders?
     
  37. unity_7UFP4-iCkwsgjg

    unity_7UFP4-iCkwsgjg

    Joined:
    Dec 13, 2017
    Posts:
    285
    yeah :( they perform the action when attacking the player just not the ai
     
  38. magique

    magique

    Joined:
    May 2, 2014
    Posts:
    3,676
    To be clear, they also performed the action when attacking AI before adding the new script and colliders?
     
  39. unity_7UFP4-iCkwsgjg

    unity_7UFP4-iCkwsgjg

    Joined:
    Dec 13, 2017
    Posts:
    285
    yeah :/ i mean they still weren't damaging but they did the attack animation
     
  40. magique

    magique

    Joined:
    May 2, 2014
    Posts:
    3,676
    Just for sanity check, disable the EnableColliders script by unchecking it in the inspector. And let me know if it's animating again.
     
  41. unity_7UFP4-iCkwsgjg

    unity_7UFP4-iCkwsgjg

    Joined:
    Dec 13, 2017
    Posts:
    285
    :O ah no it's not doing the animation now just running into each and carrying on running could it possible be a distance issue? ah wait it is took a while they were to close. But still not working when i enable that script
     
  42. magique

    magique

    Joined:
    May 2, 2014
    Posts:
    3,676
    OK, so disabling the script would be the equivalent of going back to the way you had it before. So, it isn't using attack animation against AI in either case. So, definitely another issue.

    When you say still not working with the script do you mean no animation or no damage? I thought you had gotten the damage part to work with script.
     
  43. unity_7UFP4-iCkwsgjg

    unity_7UFP4-iCkwsgjg

    Joined:
    Dec 13, 2017
    Posts:
    285
    no animation or damage towards ai only against player. Last time i checked they ai did damage was before the update until today :(
     
  44. unity_7UFP4-iCkwsgjg

    unity_7UFP4-iCkwsgjg

    Joined:
    Dec 13, 2017
    Posts:
    285
    okay got it playing the animation had to further the distance but now it attacks the player from distance :( any ideas to allow for both further distance for butting heads and close up attack for player?
     
  45. magique

    magique

    Joined:
    May 2, 2014
    Posts:
    3,676
    So, they butt heads now and do damage? But attacks on player are at distance? I'm sorry, but just unclear what's working or not working at this point.
     
  46. unity_7UFP4-iCkwsgjg

    unity_7UFP4-iCkwsgjg

    Joined:
    Dec 13, 2017
    Posts:
    285
    ah sorry i'll try explain it better :)

    My Ai butt heads after now display the attack animation (had to increase attack distance) just checked damage now and ai can damage ai :)

    Because i had to increase attack distance to allow my ai to butt heads and display their attack animation my ai now attack the player from a distance causing damage (want the ai to get close to the player to attack and cause damage)
     
    Last edited: Oct 17, 2019
  47. FrostedBrain

    FrostedBrain

    Joined:
    Sep 26, 2019
    Posts:
    13
    Hello again, I set up a new AI agent but decided to scale it down to 75 percent after I set her up. I am getting an issue with the agent sliding around the floor now when moving. If I recall correctly ; last time I had this issue you said it was my nav mesh agent size not matching up with the settings in the EM AI script which worked for that case but not for my current project.

    Could this be happening because of the scaled down agent gameobject? Should I just always scale my character objects before I set up the AI?
     
  48. magique

    magique

    Joined:
    May 2, 2014
    Posts:
    3,676
    Sounds like you need some way to dynamically change attack distance based on whether the AI are attacking a player or the AI are attacking each other. I don't have time at the moment to code something up, but you should be able to add some sort of listener to your AI that checks if it has a target and whether the target is a player or another AI and then modify the attack distance based on that. That's something that could go into your already existing AIHelper script or whatever you are calling it.

    [EDIT]
    This is the sort of thing that I think Playmaker would be good for
     
  49. unity_7UFP4-iCkwsgjg

    unity_7UFP4-iCkwsgjg

    Joined:
    Dec 13, 2017
    Posts:
    285
    would it be possible to use tag detection?
     
  50. magique

    magique

    Joined:
    May 2, 2014
    Posts:
    3,676
    Sure. In any case you'd have to write custom code.