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
  2. Ever participated in one our Game Jams? Want pointers on your project? Our Evangelists will be available on Friday to give feedback. Come share your games with us!
    Dismiss Notice

AI Behaviors Made Easy! (Walker Boys)

Discussion in 'Assets and Asset Store' started by profcwalker, Apr 22, 2012.

  1. NathanWarden

    NathanWarden

    Joined:
    Oct 4, 2005
    Posts:
    663
    Hi Ted, thanks for the compliments of our package. We want it to be as easy, smooth, and as bug free as possible. If you wouldn't mind, is it possible you can zip up a project with that issue you're having and send it to us? You can go to the Component>AI>Report a Bug and it'll open your email client (if you have one setup). If this is possible it will be a huge help to us, thanks :)
     
  2. danreid70

    danreid70

    Joined:
    Aug 28, 2010
    Posts:
    224
    Mikie,

    AI Behaviors with Unity Indie, and free version of Astar pathfinding. As long as you make sure you have Astar set up correctly (just follow the website - good docs there, too, btw), and set up a set of Nav points (transforms), and name them with sequential numbering (as shown in AIBehaviors tutorial videos), pop them into another Transform (group), and drag that group into your AIs Patrol behavior's Navigation Path Group (typing from memory, can't remember if that's the exact parameter - click "edit" for the Patrol behavior and scroll down). Then just create that script and drop it also onto your AI, and BAM! It works! And it works great! The code I put up here is the exact code you find if you follow the tutorials, plus a couple lines to automatically give the AI/Nav a target transform (each AI needs a separate one, which got to be too putzy for me, manually, to set up each AI with another transform target)... Hope I didn't make it sound too complicated - it's really not.
     
  3. RideTheT

    RideTheT

    Joined:
    Jun 11, 2012
    Posts:
    23
    Hi Nathan, thanks for the quick response, i'll send an email tonight.
     
  4. RideTheT

    RideTheT

    Joined:
    Jun 11, 2012
    Posts:
    23
    Hi Nathan, tried to file a bug but I got a delivery failure notice for this address <nathanwardendomain@mac.com>, so not sure if you guys received it. Any ideas?
     
  5. rockysam888

    rockysam888

    Joined:
    Jul 28, 2009
    Posts:
    650
  6. rockysam888

    rockysam888

    Joined:
    Jul 28, 2009
    Posts:
    650
  7. profcwalker

    profcwalker

    Joined:
    May 3, 2009
    Posts:
    243
    @chin: The question about the 2D Template. We need to actually update the page on that one. Our currently plans are to keep the 2D template system in-house for now. Let me know if you have further questions. Thank you.

    @ted: Just a quick update. Yes, we did receive it. Thank you for taking the time to submit the report.
     
  8. rockysam888

    rockysam888

    Joined:
    Jul 28, 2009
    Posts:
    650
  9. NathanWarden

    NathanWarden

    Joined:
    Oct 4, 2005
    Posts:
    663
    Hi Rocky, yes, it needs to at least be set to Navigation Static if you're using Unity's pathfinding. However, if you're using a 3rd party pathfinding tool such as the Astar Pathfinding system, you can ignore that step.

    Hope this helps :)
     
  10. jaya

    jaya

    Joined:
    Aug 12, 2011
    Posts:
    9
    Hi,

    My character (a wolf) keep heading to a tree ... not able to avoid it. At the moment I only enable one state - Patrol. I have baked the scene including the trees.

    Appreciate your help very much.

    Thank you.

    Regards,
    Jaya
     
  11. Panajev

    Panajev

    Joined:
    Mar 26, 2012
    Posts:
    42
    Hello, and... wow.... lots of information to digest at once :).

    I have a couple of requests I'd like to make to you if possible:

    1.) (very low priority since it involves work on a 3rd party tool) would it be possible to make a short video that starts from an empty scene, imports the free A*Pathfinding, and create a very very basic scene that can be connected to your AI Behaviors tool? I know, A*Pathfinding is an external tool, but it would help :).

    2.) Suppose I have a character I want it to reach its target in exactly X seconds and thus variate its speed (all my actors are non kinematic rigidbodies I move with physics forces) according to its initial distance from the target. How would I do it with your tool (again I do not have Unity Pro, but for this specific case I do not need pathfinding at all or could setup A* free... I know its target position and the initial actor position)?

    3.) How would I integrate your tool with my scripts dealing with my actors current animation state and properties (I use sprites with the ex2D framework to start and control the actual animations)? I currently, for example, control the character movement when punching (object throwing the punch cannot move for that moment, object being hit is blocked too until you finish the combo and a strong punch pushes it away or you stop punching and the actor is not currently "stunned")...

    Thank you very much for your tool and your work documenting it!
     
  12. rockysam888

    rockysam888

    Joined:
    Jul 28, 2009
    Posts:
    650
    Hi ProfCWalker and Nathan,

    Could we use this ai kit with unity free? If so, how could we deal with Nav?
    (I ask this because the upgrade price for unity 4 pro is quite high. Some users may use unity 3.x pro or unity 4 free...)

    Thanks in advance
     
  13. onepiece81

    onepiece81

    Joined:
    Feb 26, 2011
    Posts:
    2
    Very interesting and interested !!!!
    Can't wait to see the video...
     
  14. profcwalker

    profcwalker

    Joined:
    May 3, 2009
    Posts:
    243
    @rockysam: We actaully support the free Astar Pathfinding tool and have two video examples taking you step-by-step in implementing it (about 20 mins long). Be sure to check out the first page of this thread, the videos are on the first post. Let me know if you have further questions. Thank you.

    Video Tutorial 1

    Video Tutorial 2

    @onepiece81: Glad to hear you're interested in AI Behavior. If you are referring to the video tutorials, you'll want to check out the very first post. We've placed all the videos there. If it's something else, just let me know. :) Thank you.
     
  15. edcx

    edcx

    Joined:
    Jun 20, 2012
    Posts:
    9
    Hello everyone,

    I totally need AI Behavior. It's amazing. But I have a question. I'm currently working on a 2d game and I want to use this package on that game. Is this possible?
     
  16. Prof. E Walker

    Prof. E Walker

    Joined:
    Aug 20, 2009
    Posts:
    4
    @edcx: We are excited to hear you are interested in the AI Behavior tool. The system has been implemented into a 2d game environment and as long as the navigation mesh can be generated on your collision tiles it will work just right. One of the example files in the package shows how to prepare the scene for usage in a 2d environment and should get you moving in the right direction.

    Hope that helps!
     
  17. edcx

    edcx

    Joined:
    Jun 20, 2012
    Posts:
    9
    Cool thanks. By the way, I'm still new in unity and I have some other tools like smooth moves, ex2d. Can I use them with this tool? I want to use my animations and I believe that I can, right?=)
     
  18. NathanWarden

    NathanWarden

    Joined:
    Oct 4, 2005
    Posts:
    663
    Hi Ed,

    I'm not familiar with smooth moves, but the way we set up our animation system is that it sends a message to whatever script you have to receive it. The data that it sends includes the animation name that you set. That way you can use pretty much any animation system you have or want to create including things like sprite animations.
     
  19. edcx

    edcx

    Joined:
    Jun 20, 2012
    Posts:
    9
    Thanks a lot =)
     
  20. emiller100

    emiller100

    Joined:
    Jul 17, 2010
    Posts:
    39
    Do you get the full source code with this addon? What is in the plugins folder?
     
  21. NathanWarden

    NathanWarden

    Joined:
    Oct 4, 2005
    Posts:
    663
    Yes, you will get the full source code with the plugin :)
     
  22. NathanWarden

    NathanWarden

    Joined:
    Oct 4, 2005
    Posts:
    663
    Sorry emiller, I skipped right over the second question you had and didn't realize it. By default, it isn't in the plugins folder, but, you'll need to move it there for it to be useable with Unityscript. As far as this plugins' folder, we have example scenes for every state in the folder. It includes some example assets such as the "man" in training videos. In the upcoming release, which will hopefully be by next week, we will be including a scene full of AI troops that you can play in.

    Hope this answers your question.
     
  23. DavidP

    DavidP

    Joined:
    Jun 27, 2012
    Posts:
    4
    Hi Guys!

    AI Behaviors looks awesome and I'm planning to use it but I have 2 questions:
    Is it compatible with the flash export ?
    Will it work with the animations made with the animation graph of Unity 4.0 ?

    Thanks

    David
     
  24. NathanWarden

    NathanWarden

    Joined:
    Oct 4, 2005
    Posts:
    663
    Hi David,

    1) I just exported a scene I have been working on for the past couple of days out to Flash and it seems to work just fine.

    2) Our animation system is loosely coupled to the main behaviors system so it should work well with any animation system you want to hook it into. So, yes it should work with the new animation system. I'm sure we'll make an example script for integration with that once we get our hands on 4.0 :)
     
  25. nuverian

    nuverian

    Joined:
    Oct 3, 2011
    Posts:
    2,052
    Looks promising. How easy or hard would it be to create custom behaviours? Or is this plain scripting an action like you would do for behaviour trees?
     
  26. Xander-Davis

    Xander-Davis

    Joined:
    Apr 23, 2011
    Posts:
    414
    OMG I'm so happy you guys made this, Chad! This is exactly what I was hoping for! While working at another studio on CryEngine 3, I tried to dive into indie Unity development head first for about five months straight last summer, but back then they didn't have pathfinding and there wasn't a good, easy Inspector-controlled AI system. Nothing like this. It basically was a show stopper for me. And now you guys have completely filled that gap perfectly. The system is so easy to use, it reminds me of when I would mod Bungie's Marathon with their Forge and Anvil tools.

    Thank you thank you thank you! I think this has just become the new core element driving my projects' gameplay. You guys rock!

    PS: I see you're in Texas! I was just in Austin from Fall 2011 to Spring 2012 working at Vigil on Darksiders 2. Now I'm in Vegas wrapping up End of Nations, the first MMO-RTS. Austin was fun! 6th Street...
     
  27. drewradley

    drewradley

    Joined:
    Sep 22, 2010
    Posts:
    3,063
    I have A* Pro which can make nav meshes. How hard or easy is it to use those instead of the unity created nav meshes in Unity Free? Thanks!
     
  28. NathanWarden

    NathanWarden

    Joined:
    Oct 4, 2005
    Posts:
    663
    Hi nuverian, as of this upcoming release, which is getting super close, you'll be able to write custom states and triggers very easily. We'll be putting up a video covering how to do this and what it means for you.

    Xander, thanks so much for the compliments, they mean a lot. We'll have our new version up in the next week or two with some really nice additions that we think you and others will really appreciate.

    Hi Drew, we have a video covering how easy it is to implement our system in with other pathfinding systems and we use Astar as the example 3rd party system.

    The videos are here:
    Part 1
    Part 2
     
  29. drewradley

    drewradley

    Joined:
    Sep 22, 2010
    Posts:
    3,063
    Saw that but that's for the free version which doesn't include a nav mesh. I am specifically wondering if I can use a nav mesh made with A* pro, not free. Is it the same as the free version or can I simply substitute the nav mesh made in A* for the nav mesh made with unity pro?
     
  30. NathanWarden

    NathanWarden

    Joined:
    Oct 4, 2005
    Posts:
    663
    I'm not familiar with pro, but I'm sure setting it up is probably the same as the free version, especially if they have the AIFollow script as a standard script. Our system also doesn't care whether the pathfinding system is using a nav mesh or way points, it just needs to tell the pathfinding system where it wants to go.

    So, more than likely if the AIFollow script comes with A* Pro you're good to go and can just use the code at the end of video 2 which integrates with the AIFollow script. Otherwise, let us know and we'll see what we can do to get you setup with the pro version of Astar.

    Hope this helps,
    Nathan
     
  31. drewradley

    drewradley

    Joined:
    Sep 22, 2010
    Posts:
    3,063
    Thanks! Just got it so I'll let you know how it works with the nav meshes made with astar pro.
     
  32. nuverian

    nuverian

    Joined:
    Oct 3, 2011
    Posts:
    2,052
    I havent yet made a purchase as I am waiting the update to see how it will be possible to implement triggers and events. So in essence if I am right, your tool is an FSM in the backend? Does this means that 2 events can't run simultaneusly? It will be a nice feature to have in future updates. Just a suggestion.

    Also, I appreciate the ready behaviours, but I would like to see premade behaviours or triggers more generic rather than combat based as of now and not redundant. Cause I had that redundancy feeling with the current ones (as seen in videos).
    Same goes for triggers. For example Instead of "Low Health" or "High Health", you could have a type of expression allowing the designer to hook a variable and a symbol (<, >, = etc) instead of having this limited to Health.

    Now please don't get me wrong. I am just making suggestions here cause obviously I like your product from what I've seen and would like to give feedback. Of course I will do this again once the new update is out and I probably go and make my purchase.
     
  33. Xander-Davis

    Xander-Davis

    Joined:
    Apr 23, 2011
    Posts:
    414
    Hi Nathan— thanks and looking forward to the update!

    In the meantime, I'm trying to get everything up and running. So far so good, except for two short things.

    1) I got the dead state to trigger, but how can I set the enemy's health? Say I want it to just be 30 instead of 100.

    2) Also, while the enemy projectiles do hit the Player (tagged Player) with a Character Controller for a collider, the projectile does not successfully seem to subtract a hit from the PlayerStats attached. I get no debug warning of a hit or death over time. Advice?

    Thanks!
     
    Last edited: Jun 30, 2012
  34. yuewah

    yuewah

    Joined:
    Sep 21, 2009
    Posts:
    98
    I have two team of AI bot, is it possible to allow them to battle to each other ?
     
  35. NathanWarden

    NathanWarden

    Joined:
    Oct 4, 2005
    Posts:
    663
    Hi Xander, sorry, I think your post got lost in my email.

    1) You can call the SetHealthValue, AddHealthValue, and SubtractHealthValue on the AIBehaviors script either directly or with SendMessage and the appropriate value. You can call GetHealthValue to get the current health amount.

    2) It's probably because SubtractHealth is a static method and you might be calling SendMessage on it. If this is the case, it won't work. This will be changed in the next release to be a standard instance method as I'm now trying to avoid using the singleton pattern on much of anything. For now you can call PlayerStats.Instance.SubtractHealth(damageAmount) in a C# script when it hits. Again, this will be changed to accommodate SendMessage in a week or so when we send out our next release.

    Also as a side note, anything in the scripts folder that has: AIBehaviorsCharacterAnimator, Alarm, Crosshairs, ExampleAttackComponent, PlayerStats, etc is not part of our system, but is provided as something to use as an example to springboard off of. This folder will likely be named "ExampleScripts" in the upcoming release.

    Thanks Xander, hope you are enjoying it :)
     
  36. NathanWarden

    NathanWarden

    Joined:
    Oct 4, 2005
    Posts:
    663
    That's a great question! :)

    You could definitely get two bots reacting off of each other pretty easily out of the box, making it actually look fairly clever would take some work with pretty much any AI system out there, but definitely possible and even more possible with our upcoming release.

    So, in a nutshell... yes it is possible. :)

    Hope this helps,
    Nathan
     
  37. yuewah

    yuewah

    Joined:
    Sep 21, 2009
    Posts:
    98
    It is great to hear that, so when you plan to release the next version ?

    btw, any new behaviors for the new release ? flock, wander and more.
     
    Last edited: Jul 3, 2012
  38. yuewah

    yuewah

    Joined:
    Sep 21, 2009
    Posts:
    98
    If I want to Attack together with Follow , how to do that ? Is it create a new state by merging Follow and Attack State script ?
     
  39. nuverian

    nuverian

    Joined:
    Oct 3, 2011
    Posts:
    2,052
    Is the update closing by?
     
  40. DavidP

    DavidP

    Joined:
    Jun 27, 2012
    Posts:
    4

    Hey guys, I just wanted to let you know that I've started my projet using AI Behaviors and so far it works like a charm! It's easy to use and does everything I want. Thanks for the great work.
     
  41. NathanWarden_old

    NathanWarden_old

    Joined:
    Oct 4, 2005
    Posts:
    37
    Hi yuewah,

    You can do something like that if you want to, however you may want to hold off on creating that until our upcoming release (which is really soon) as it will be much much much easier to integrate. :)
     
  42. NathanWarden_old

    NathanWarden_old

    Joined:
    Oct 4, 2005
    Posts:
    37
    Hi nuverian, yes, it's very very soon. We just need to do a few minor things and then submit it and hope that all goes well :)
     
  43. NathanWarden_old

    NathanWarden_old

    Joined:
    Oct 4, 2005
    Posts:
    37
    Thanks David, we're always glad to hear that it's working great for our customers :)
     
  44. danreid70

    danreid70

    Joined:
    Aug 28, 2010
    Posts:
    224
    Bump. Anxiously awaiting update! Can't wait to get my grubby little eager hands on it! ;)

    How easy will it be to spawn character AI "out of the box" with the new update? With the current build, I have to do a little setup code to tie in a few parameters (patrol group, etc) after I instantiate and reset a few params, but I'm sure there's no way to avoid that.

    I'd also like to tie in the animation code to stream the animation state with network serialize, so that the player initializing the server runs the AI, and the clients get just "AI-less" drones on their end, if "networkview.ismine" is false. That way the AI will run only on the server, for computer controlled AIs including turrets, enemies, etc, and the clients just get updated position, rotation, animation, and action states for everything else in the "world" from the server. I know that's well beyond what the AI is intended for, but just wanted to "vent" what I'm working on. And if you guys might have any comments on what I'm doing, if you have any feedback based on the best way to go about this in case there's a better way?

    I'm thinking that if I spawn every "character" and have the spawned check to see if it's the server or client, then have 2 versions of each AI (AI on server, or "drone" on client) and spawn the appropriate prefab. Sorry - thinking out loud. ;)

    Anyway, can't wait to see update! Preset prefabs will really help, and I can't WAIT to just drop them into my project and watch them run around causing mayhem! ;)

    --Dan
     
  45. Zozo2099

    Zozo2099

    Joined:
    Jul 15, 2012
    Posts:
    478
    Can we know please when the update will be released? And will be there a future sale on it?

    Thanks
     
    Last edited: Jul 15, 2012
  46. nuverian

    nuverian

    Joined:
    Oct 3, 2011
    Posts:
    2,052
    I'd like to know how easy is this to be integrated with SimplePath. I believe I would have a better right to know when I purchase this, but I'm waiting the update.
     
  47. theLittleSettler

    theLittleSettler

    Joined:
    Jul 14, 2012
    Posts:
    36
    Hey,

    I can see that this system works well on an individual level, or with a handful of NPCs. How many can it run before it lags at, say, 60fps? I understand that it would vary allot, an estimate will do.
     
    Last edited: Jul 17, 2012
  48. NathanWarden_old

    NathanWarden_old

    Joined:
    Oct 4, 2005
    Posts:
    37
    Hi Dan, you have a lot of interesting thoughts about networking that will definitely be discussed and considered for a future update. Also, we will have some presets and the ability to make your own presets in not this upcoming update, but the following one after that.

    Hi Zozo, the next release is pending approval on the asset store currently :) As for a future sale, the current price is the early adopter sale price and will only go up from here. Once the next update is released probably in a day or so, the price will go up so you may want to grab it up today.


    I'm not familiar with simple path, but if simple path has an intuitive way to command your navigator to move, then it should be as simple as the Astar Pathfinding video we put together.


    Hi theLittleSettler,

    Chances are highly likely that you will hit a bottle neck with draw calls of you own content long before you have a bottleneck with our system. It also depends on what you have the AI characters doing. If you have a lot of "Line of Sight" triggers set up, you'll hit a bottle neck far sooner than if you use it sparingly since it uses a raycast. With that said, I estimate that your average case AI should be able to have several hundred active in a scene at once.

    You can also set the AIBehaviors active state by calling the local SetActive method on it. So when you're within distance of the AI, let's say about 1000 game units, have it call SetActive(true), and when you're beyond that 1000 game units call SetActive(false); That way you could probably easily have thousands of them in a scene at once without incurring much of a hit at all.

    Hope this helps everyone,
    Nathan
     
  49. NathanWarden_old

    NathanWarden_old

    Joined:
    Oct 4, 2005
    Posts:
    37
    I just did some performance testing...

    The conditions are as follows, I have an agent setup using the Line of Sight trigger (since that is probably the worst case trigger because it uses a Raycast). I shut off the avatar object and all of it's children since that has to do with GPU and Unity's internal processing. I duplicated one agent every 10 frames until the frame rate dropped below 60. The computer has an AMD Phenom CPU at 2.7 GHz.


    Test 1: Active agents
    The point at which the frame rate goes below 60 fps is when approx 250 to 275 completely active agents are in the scene.

    Test 2: Inactive agents
    Using the AIBehaviors.SetActive(false) instance method, the point at which the frame rate drops below 60 fps is at about 325 to 350 agents.

    Test 3: Inactive GameObjects
    I started to experience some slight, but not annoying, jerkiness at around 2000 agents who's root gameObject was completely shut off, thus they don't run code on any of the components at all.

    Conclusion:

    First, you can easily have up to 200 active agents in a scene at once. Secondly, once an agent is beyond a reasonable viewable distance, you really should just make the AIs gameObject(s) inactive. This is the standard Unity advice on most other systems as well. Finally, with very little effort on the developers' end, they can easily have well over 1500 AI agents in a scene at once given that only the ones within a reasonable distance are actually active.


    Edit: I also just checked when going down to 30 fps and the numbers for tests 1 and 2 doubled.
     
    Last edited: Jul 18, 2012
  50. nuverian

    nuverian

    Joined:
    Oct 3, 2011
    Posts:
    2,052
    Nice info.
    Can you share anyhing about the update since it's done and awaiting approval.
    By the way SimplePath is as simple as moveto x,y,z so I guess that will be trivial.
     
unityunity