Search Unity

  1. Check out our Unite Austin 2017 YouTube playlist to catch up on what you missed. More videos coming soon.
    Dismiss Notice
  2. Unity 2017.2 is now released.
    Dismiss Notice
  3. The Unity Gear Store is here to help you look great at your next meetup, user group or conference. With all new Unity apparel, stickers and more!
    Dismiss Notice
  4. Introducing the Unity Essentials Packs! Find out more.
    Dismiss Notice
  5. Want to see the most recent patch releases? Take a peek at the patch release page.
    Dismiss Notice
  6. Unity 2017.3 beta is now available for download.
    Dismiss Notice

[RELEASED] Emerald - AI (Dynamic Wildlife, Breeding, Predators & Prey, Herds, NPCs & more!)

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

?

Which (in development) feature would you like to see the most implemented with Emerald Animal AI

Poll closed Oct 1, 2015.
  1. Predator and Prey system support (allows animals to hunt and flee from each other)

    12 vote(s)
    17.4%
  2. Pack/Herd Support (allows for animals to stay together and hunt or graze)

    5 vote(s)
    7.2%
  3. Mating Support (allows animal to reproduce Minecraft style to help keep populations balanced)

    5 vote(s)
    7.2%
  4. Combat Support (will include a working example system of fightable and huntable animals)

    10 vote(s)
    14.5%
  5. All of the above (they are all equally as awesome and they all need to be implemented)

    37 vote(s)
    53.6%
  1. Teila

    Teila

    Joined:
    Jan 13, 2013
    Posts:
    5,942
    Thanks, BHS! Hope that isn't too long because honestly, I was waiting to make a video until the last release and now with the death animations gone, it will lose some of it's impact. I realize that for the FPS crowd, this isn't important but many of us are using Emerald for RPGs. It would be nice if we could know ahead of time when things will be removed in the latest edition, before we download it.
     
  2. BHS

    BHS

    Joined:
    Dec 21, 2009
    Posts:
    2,973
    We can send you an updated script that has death animations instead of a dead replacement, if that will make things easier?
     
    Shawn67 and Teila like this.
  3. BHS

    BHS

    Joined:
    Dec 21, 2009
    Posts:
    2,973
    _invalidusername, Shawn67 and Teila like this.
  4. Teila

    Teila

    Joined:
    Jan 13, 2013
    Posts:
    5,942
    Yes, it would! Thank you. :)
     
  5. MahaGaming

    MahaGaming

    Joined:
    Feb 25, 2014
    Posts:
    80
    be nice to have option like pet animal that follows player and attacks predators or anything with Tag Enemy :).

    Will you be adding a respawn manager
     
    Last edited: Aug 19, 2015
  6. paulojsam

    paulojsam

    Joined:
    Jul 2, 2012
    Posts:
    435
    when i change the value to zero it goes to 1e-05, the nav mesh height
     
  7. Dawar

    Dawar

    Joined:
    Dec 7, 2014
    Posts:
    78
    I want eat animation for predator when predator hunt the prey than predator eat the prey meat(predator eat animation) for some second than disappear the prey body. it will be look more realistic.
     
  8. _invalidusername

    _invalidusername

    Joined:
    Jul 1, 2014
    Posts:
    34
    I'm having an issue with damage being dealt to the player from far away. A predator will chase me, I climb onto a rock and still receive attack damage even though the predator is a good 5 meters away. I suspect (I will do some proper tests in the morning) that it only occurs when run attack animations are enabled.

    How is the attack range of a predator calculated?
     
  9. BHS

    BHS

    Joined:
    Dec 21, 2009
    Posts:
    2,973
    These are both great ideas. We will see what we can add this for the next update.


    We will also look into adding this for the next update.


    It is calculated by the distance between the player and the predator. When your player goes off the NavMesh (up on the rock) the animal is still using the waypoint generated when the player left the NavMesh. So, it continues to calculate the distance using that same point.

    We can fix this with our next update by adding in some code that checks when the player goes off the NavMesh. If they do, and the player is the predator's current target, the predator will wait and idle in aggressive stance for a certain amount of seconds before returning to its starting position. This will be adjustable within the Emerald Editor.
     
  10. _invalidusername

    _invalidusername

    Joined:
    Jul 1, 2014
    Posts:
    34
    Ok cool, sounds like it should be fairly simple for me to fix myself. Thanks for the response!
     
  11. BHS

    BHS

    Joined:
    Dec 21, 2009
    Posts:
    2,973
    You're welcome. It will be.

    We have a lot planned for our next update.
     
    Shawn67 likes this.
  12. BHS

    BHS

    Joined:
    Dec 21, 2009
    Posts:
    2,973
    For those of you wondering what the capabilities for Emerald are, there are many uses Emerald is capable of besides just animals.

    Emerald v 1.1 (our current version) can also be used for NPCs. These NPC are capable of hunting animals using the same logic as a predator. We will demonstrate this feature with video examples. We will also provide a tutorial through our wiki site.

    Emerald can also be used for enemy creatures and NPCs. We have already tested this with several tests with awesome results. We will also post an example of this with new demo videos. We will also provide a tutorial through our wiki site.

    We are also working on support for a companion system that will allow players to have AI follow them around and fight for them. This will also have avideo demonstration.

    With our next version, we will include NPCs that hunt, enemy NPCs and creatures, and a companion example.

    For added realism, we will make most of these actions callable through public functions so they can be accessed with something like UniStorm (our day and night weather system), or other time of day systems, that will allow custom scripts to be used to influence NPC's actions. This could allow NPCs to only go hunting when it's cold or at night, as well as certain animals and creatures having certain actions for specific times of day or weather (like Skyrim or Oblivion)

    By UniStorm, we mean our day and night weather system here: http://forum.unity3d.com/threads/un...ystem-released-now-with-playable-demo.121021/

    Please give us your feedback on this. This will all be available with our next update.
     
    Last edited: Aug 24, 2015
    julianr, Teila and TRoNDaNeflin like this.
  13. Teila

    Teila

    Joined:
    Jan 13, 2013
    Posts:
    5,942
    Sounds great!

    One thing that would be nice is to let animals and NPCs hunt more than one tag. So an NPC can hunt "huntables" but also "players". Also, it would be nice if prey could also hunt, since in the food chain, some predators hunt other predators and some prey also hunts.
     
    Shawn67 likes this.
  14. Dawar

    Dawar

    Joined:
    Dec 7, 2014
    Posts:
    78
    Great Idea @BHS
    here I also suggest some thing more.when I go for hunting with my friend than we also bring our hunting dogs with us.when we hunt some birds than these hunting dogs bring this bird for us.
    so
    1.also add hunting dog with Npc which bring the hunting prey to NPCS.
    2. add npc hunting with cross bow and guns.
    3. hunt only one prey at one time. than bring it to own place for eating or to store as in Strong Hold game.
    4. if you add day night cycle. than make some animal graze at night and some animal graze only at day time.
     
  15. BHS

    BHS

    Joined:
    Dec 21, 2009
    Posts:
    2,973
    These are great suggestions. We will see what we can do.

    By a day and night system, we meant the one we have already created which is our system UniStorm here:
    http://forum.unity3d.com/threads/un...ystem-released-now-with-playable-demo.121021/

    It is very easy, even now, to implement actions based on weather and time. We will provide an example of how to implement UniStorm through our wiki site.
     
    julianr likes this.
  16. Shawn67

    Shawn67

    Joined:
    Jan 2, 2014
    Posts:
    1,924
    Is it safe to assume these will be hooks available for us to use regardless of whether or not we have UniStorm? For example if we have our own custom scripts or use another day/night system that can handle time/weather-based AI?
     
    Teila likes this.
  17. BHS

    BHS

    Joined:
    Dec 21, 2009
    Posts:
    2,973
    Yes, they will simply be public functions that can be called to change an AI's current action. It won't matter what day and night system you use. We are, however, advertising it with our UniStorm weather system.
     
    Teila and Shawn67 like this.
  18. Locky

    Locky

    Joined:
    May 14, 2015
    Posts:
    86
    I am having difficulty with the animations playing. My animal model slides around as it should but the animations are not playing unless I apply an Animator Controller and drag the animations into that. But when I do that, the animations play based on how I arrange them in the Animator Controller, not based on the animations I put into the Animal AI interface (for Idle, walk, run, etc). As a result, my animal will walk in place, or idle while he slides across the ground.
    Is this a bug or am I not setting it up correctly? I know I have the correct names entered, because I linked to the animation files (I didn't type them in).
     
  19. Shawn67

    Shawn67

    Joined:
    Jan 2, 2014
    Posts:
    1,924
    I had the same issue before I remembered I had to make a NavMesh of my terrain. Make sure you have done that.. :)
     
  20. Locky

    Locky

    Joined:
    May 14, 2015
    Posts:
    86
    Thanks Shawn67,

    Yes, I have made the NavMesh. The animal actually does move about the navmesh as directed by Animal AI, so the movement part is working. It is just that the individual animations I entered do not. UNLESS I apply the animator controller, at which time it takes over and determines how the animations play.
     
  21. Shawn67

    Shawn67

    Joined:
    Jan 2, 2014
    Posts:
    1,924
    Sounds like you are using Mecanim creatures.. I'm not sure whether or not Emerald works with Mecanim atm. Everything I've tested with has been using legacy animations. I'll have to leave that one to @BHS to answer.

    I know with Legacy, Emerald doesn't replace Unity's Animation component. The model still needs to have it with the animations assigned for Emerald to be able to use them. Both scripts coexist on the model and my models work fine. With Mecanim, I think the whole way animations are called may be different. Don't quote me on that, just my assumption.
     
  22. Locky

    Locky

    Joined:
    May 14, 2015
    Posts:
    86
    I actually don't know if it is Mecanim animation or not since I downloaded it from the Asset Store. I'm working on a second animal now that I have modeled, rigged and will animate myself. That way I know what I am getting.

    I would be interested in seeing how one of your Animation Components is set up. I can't help but think that I am doing something very simple that is preventing it from working properly.
     
  23. Licarell

    Licarell

    Joined:
    Sep 5, 2012
    Posts:
    434
    That would be a bummer if this doesn't work with mecanim...
     
  24. Shawn67

    Shawn67

    Joined:
    Jan 2, 2014
    Posts:
    1,924
    I'm not really setting anything up in it. I'm just using the defaults of the models.. The screenshot below shows it for one of my Emerald-enabled animals. This is pretty much the way it was setup from the developer. The only thing I changed was the default animation, switching it to walk from an idle animation. But I think Emerald pretty much overrides that default and plays whichever animations you have setup for the different AI behaviors depending on what state the animal is currently in. I think the only thing required of the animation component is to have the animations selected for the various Emerald behaviors be included within the Animations array of the Animation component. Again, I'll leave for @BHS to confirm, but that is my assumption since it seems to be that way with other scripts accessing animations.

    EDIT: Oops.. helps to include image... lol

    AnimalAnimationComponent.jpg
     
  25. Locky

    Locky

    Joined:
    May 14, 2015
    Posts:
    86
    Thank you for sharing this.

    Mine is COMPLETELY different. I am using Unity 5.1 BTW.
    When I drop my animal model (containing the animation), it does not have the "Animation" component at all like yours does! Instead it automatically adds the "Animator" component.
    So I had never set up an array of animations or anything.

    I just added the Animation component and setup an array, but it still doesn't work. Thanks for trying though.
     
  26. Shawn67

    Shawn67

    Joined:
    Jan 2, 2014
    Posts:
    1,924
    Animator is used by Mecanim.. Animation is used by Legacy. Animation wont work if your model is set up for Mecanim which it sounds like it might be. I'm using 5.1 as well.
     
  27. Locky

    Locky

    Joined:
    May 14, 2015
    Posts:
    86
    Strange that it defaults to using Animator and Mecanim. I'm just creating a regular bone animation in 3DSMax and exporting to FBX. I wonder why it sees the animation as it does? I
     
  28. Locky

    Locky

    Joined:
    May 14, 2015
    Posts:
    86
    Problem Solved!!
    I don't know what made me think of this but this is what I did:

    After bringing the model in, select it in the Projects window
    On the Inspector, select the “Rig” tab
    Change the “Animation Type” from “Generic” to “Legacy”

    Now it is a Legacy animation rather than Mechanim. Whew. Well that took most of the day. Thanks for your assistance!
     
  29. Teila

    Teila

    Joined:
    Jan 13, 2013
    Posts:
    5,942
    This is great. However, there is one significant problem for some of us. Our NPCs use the same animations as our players and are Mecanim. So if we use BHS for the player characters, then we cannot use the animations we have ready to go and will have to make special legacy ones for the NPCs.

    Our testing changing the mecanim NPCs ones we have to legacy have not had very good results.
     
    BHS likes this.
  30. 99thmonkey

    99thmonkey

    Joined:
    Aug 10, 2012
    Posts:
    476
    Yes, you definitely need two "buttons" with one being legacy animation and the other being Mecanim.
     
    BHS likes this.
  31. BHS

    BHS

    Joined:
    Dec 21, 2009
    Posts:
    2,973
    We plan on adding support for Mecanim. It should be available with our next update. It will be be a pull down menu where you can choose Legacy or Mecanim.
     
  32. Teila

    Teila

    Joined:
    Jan 13, 2013
    Posts:
    5,942
    Great! I am glad. We were looking at other options and am very happy that we won't have to do that. We like Emerald. :)

    Thanks.
     
  33. Locky

    Locky

    Joined:
    May 14, 2015
    Posts:
    86
    I am trying to get my Player to kill an Animal. I am using UFPS and have followed the instructions here:
    http://emerald-animal-ai.wikia.com/wiki/Tutorials
    But the animal doesn't die.
    Would it be possible to have a video made showing this process?
     
  34. riquid

    riquid

    Joined:
    Mar 18, 2015
    Posts:
    18
    I'm considering Emerald animal ai for my project. I just wanted to ask, are there any future plans to add support for a* pathfinding instead of the default unity navmesh? If there are no plans for a*, would it be terribly hard for an experienced coder to add into the system?
     
  35. Locky

    Locky

    Joined:
    May 14, 2015
    Posts:
    86
    Has nobody else had this problem? Is everyone else able to kill an animal with their FPS? What am I missing?

    I followed the above mentioned instructions on several kinds of objects. It worked intermittently with an imported object (with several errors), but not at all with objects containing animation. And not with any weapon other than melee.

    Surely I am not the only one? Can the developer please respond?
     
  36. Dawar

    Dawar

    Joined:
    Dec 7, 2014
    Posts:
    78
    I use RFPS
    and it work for me.
    you can check layer and also check the the ray hit the animal collider or not.
     
  37. thedreamer

    thedreamer

    Joined:
    May 13, 2013
    Posts:
    218
    Are there any plans to support the flying bird?
     
  38. jf3000

    jf3000

    Joined:
    Dec 31, 2013
    Posts:
    151
    Will you change the option for the health please so its not limited and doesnt produce an error like this:

    5e+07
     
  39. BHS

    BHS

    Joined:
    Dec 21, 2009
    Posts:
    2,973
    1) Could you please provide more details?

    2) Are hits registering on your animal?

    3) Do you have a Dead Replacement object assigned?

    4) Are you receiving an errors?

    5) Do you have your tag setup correctly, both in the Editor and on the GameObject? Not doing so would make animals not hitable.

    6) Is your animal receiving damage?

    Emerald does work with UFPS, that's what we used in all of our demo videos. It also works for our other customers. So, maybe there was a step that was missed.

    If you could answer theses questions, would be happy to assist you.

    Like I've stated below check to make sure you have eliminated these factors:

    You need to make sure that your camera isn't animating or that the animations are influencing the camera. The hit calculations are done by getting checking the center of the screen with a RayCast collision to see if an animal is present. If they are, and they are within the appropriate distance, it will send an attack to the animal.


    We do plan on adding a custom pathfinding solution. If you wanted to add it yourself, I don't think it would be terribly hard. You would just change some of the functions where the NavMesh calculations are to your own custom solution.


    You need to make sure that your camera isn't animating or that the animations are influencing the camera. The hit calculations are done by getting checking the center of the screen with a RayCast collision to see if an animal is present. If they are, and they are within the appropriate distance, it will send an attack to the animal.


    We do want to implement some sort of system that handles flying animal/creatures. We will see if we can have it by the next update.

    We would also love the flying system so we could implement a dragon example, possibly like Skyrim.


    It shouldn't be limited and that's strange you're getting the number.

    We will add this to our list of things to look into and fix if it needs to be.
     
  40. Teila

    Teila

    Joined:
    Jan 13, 2013
    Posts:
    5,942
    Any way to have multiple prey and/or predators?

    At the moment, our NPCs can hunt deer but not players. Deer have the tag huntable as do all small prey animals, but players have the Player tag. Also, it would allow us to give specific names to the tags in case we need to use them for other things in Unity.

    Predator would be good too so we can use the tags for other things and use the tag Bear, Wolf, etc.
     
    Shawn67 and 99thmonkey like this.
  41. Locky

    Locky

    Joined:
    May 14, 2015
    Posts:
    86
    When nothing is working, I have found the best method is to strip everything away to the bare basics. I am actually having two problems:
    1. Getting the animations to play on the animals
    2. Getting the animals to die from attacks with the UFPS weapons

    I had intermittent success with both of these yesterday but tried to recreate it the past three hours and now I can't get anything to work. So lets start super basic; a known good. Here is what I did in an attempt to enable the player to attack and kill an animal:

    Opened the accompanying example scene "Fleeing Animals Example"
    Saved it with a different name
    Deleted the "Player" cube
    Inserted a UFPS AdvancedCharacter
    Tagged it "Player"
    Expanded the AdvancedCharacter so we can see "WeaponCamera"
    Add the Emerald Animal AI scripted named "PlayerWeapon" to "WeaponCamera"

    Now if I am not worried about the player receiving damage; just giving damage to the animals, then this should work right? It doesn't for me, so maybe we can start there. By the way, I tried mostly melee attacks, but also the machine gun. Neither had any effect.

    To answer your questions:
    I do not know if hits are registering on my animal. I applied the "Dead Cube" to them so I know when they die. But I do not know how to determine if they are receiving damage. Yesterday my animal died intermittently. Today they ignore my attacks.

    Yes. I have the “Dead Cube” assigned as a Dead Replacement

    I am receiving errors. For now I will ignore the ones from my previous scenes because I don't know if they are related to animations or to something else.
    The error I get for the above scene:
    MissingMethodException: The best match for method Damage has some invalid parameter.

    I am not clear on what you mean when you say "make sure that your camera isn't animating or that the animations are influencing the camera." The camera is part of the UFPS character controller, so it is moving. Is that what you mean? Also, how would animations influence the camera?
     
  42. Tovrin

    Tovrin

    Joined:
    Jul 15, 2015
    Posts:
    62
    I've only begun to delve into Emerald and a bit of a noob here, so please bear with me.

    The standard AI seems to be very much predator and prey. Would it be possible to get a "defensive" AI, whereby if another predator (or the player) encroaches on the mob's "circle of influence", it's first instinct is to either flee or growl/roar and only attack after the "antagonist" has remained in the circle after a period of time.

    The kind of behavior I'm thinking of a bear or wolf where it'll put on an aggressive display first and only then attack if the aggressive display isn't working.
     
    Teila likes this.
  43. jf3000

    jf3000

    Joined:
    Dec 31, 2013
    Posts:
    151
    Tovrin, thats already in place and is based on the first size of person/creature etc compared to the second and there size. So if you had a dino and a person walked in then the person would be harmed, youd change this in the settings the small, medium and large.
     
  44. Teila

    Teila

    Joined:
    Jan 13, 2013
    Posts:
    5,942
    I am not sure this is the same thing Tovrin meant. In your scenario, the predator would completely ignore the dino as it is too big. Instead he should react, either by fleeing or growling/roaring in a defensive manner.

    I like the idea of the animal reacting first and then either fleeing or attacking next rather than the way it is now.
     
  45. BHS

    BHS

    Joined:
    Dec 21, 2009
    Posts:
    2,973
    I like this suggestion. We will be sure to implement something like this for the next update.



    First off, if you are receiving errors, this could possibly cause something to not work right.

    The UFPS system doesn't influence the animal damage in any way. You purely use the PlayerWeapon script. Make sure you disable the UFPS attack system. You are only using it for its animations. Maybe its weapon system is conflicting with Emerald's.

    I'm not sure why animations aren't working for you animals. If they are applied properly, they should work. We tested this numerous times with 10+ different animals even from different packs.

    If you are receiving any errors, we need to know what they are so we can help. I'll be able to find out exactly what's wrong if I have all the errors you are receiving.

    The camera uses the center of the screen to calculate the RayCasts to hit your animals. If your camera, for some reason, was being animated, not including UFPS, than it could affect the system, but it sounds like you're not.

    You can check to see if your animals are receiving damage by viewing their Emerald script. They will have a variable called health. If it is anything less than its starting health after you have hit it, it is working.

    There are 2 health scripts, one for animals, and one for the player. Make sure you have the appropriate ones applied.



    This is a great suggestion. We do plan on adding an aggressive behavior type with the next update that will do just this. Our system also isn't limited to animals. It can be used for NPCs as well.
     
    Teila likes this.
  46. jonfinlay

    jonfinlay

    Joined:
    Aug 25, 2015
    Posts:
    499
    I'm getting exactly the same problem as Locky when using UFPS. When I shot the object it crashes with the following message:

    MissingMethodException: The best match for method Damage has some invalid parameter.
    System.MonoType.InvokeMember (System.String name, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object target, System.Object[] args, System.Reflection.ParameterModifier[] modifiers, System.Globalization.CultureInfo culture, System.String[] namedParameters) (at /Users/builduser/buildslave/mono-runtime-and-classlibs/build/mcs/class/corlib/System/MonoType.cs:520)
    UnityEngine.SetupCoroutine.InvokeMember (System.Object behaviour, System.String name, System.Object variable) (at C:/buildslave/unity/build/Runtime/Export/Coroutines.cs:18)
    UnityEngine.Component:SendMessageUpwards(String, Object, SendMessageOptions)
    vp_HitscanBullet:DoHit() (at Assets/UFPS/Base/Scripts/Gameplay/Combat/vp_HitscanBullet.cs:166)
    vp_HitscanBullet:Start() (at Assets/UFPS/Base/Scripts/Gameplay/Combat/vp_HitscanBullet.cs:68)

    I followed the tutorial exactly how it was written. I tested it without Emerald Animal AI and it works fine.
     
    Locky likes this.
  47. BHS

    BHS

    Joined:
    Dec 21, 2009
    Posts:
    2,973
    It looks like it's because you are still using the UFPS hit/damage system. Are you using only Emerald 's?

    This is very strange though. We will certainly look into what's causing it.
     
  48. jf3000

    jf3000

    Joined:
    Dec 31, 2013
    Posts:
    151
    The more I use this the more I am finding a niche for this. Having set the area for the ai to walk in which is just inside the circle, what happens if I only want the ai to walk within a path area of 100m which is up and down a path, I create just zoom the circle out and have the ai walking all over the place, how can I have it walking within a certain area?
     
  49. Pandur1982

    Pandur1982

    Joined:
    Jun 16, 2015
    Posts:
    191
    I have a question, can i use the emerald ai for fish in underwater Terrain scene?
     
  50. Locky

    Locky

    Joined:
    May 14, 2015
    Posts:
    86
    Note that I did get the animations to work correctly and consistently once I modeled, rigged and animated my own animal.

    I had been using the free Horse model from the Unit Asset store previously and it was using this model that I encountered the intermittent behavior. I am still not sure why that is. The Rig was set to "Generic" rather than "Legacy." I changed it to "Legacy" so you would think that would have done it; but it was inconsistent.

    Anyway; one problem solved. It's pretty cool to see a pack of my animals running around and sniffing the environment.