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

AI Behaviors Made Easy! (Walker Boys)

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

  1. dreadt9

    dreadt9

    Joined:
    Jan 13, 2012
    Posts:
    143
    (3 Days later)

    ...

    You can take as long as you want ProfCWalker, no-one is rushing you as you are doing an amazing job... Just don't give false dates and times
     
  2. OmniverseProduct

    OmniverseProduct

    Joined:
    Feb 26, 2012
    Posts:
    1,569
    You do realize it takes time for unity to approve a product right?
     
  3. dreadt9

    dreadt9

    Joined:
    Jan 13, 2012
    Posts:
    143
    nope... How long usually? (I seriously have no idea, I thought it was like a day)
     
  4. OmniverseProduct

    OmniverseProduct

    Joined:
    Feb 26, 2012
    Posts:
    1,569
    I don't know how long to be honest. I think it depends. I've never submitted anything to the asset store.
     
  5. dreadt9

    dreadt9

    Joined:
    Jan 13, 2012
    Posts:
    143
    Well if it usually is long, then I take back the last bit:
    "Just don't give false dates and times"

    I mean the first bits though as it is awesome work :D
     
  6. appliquette

    appliquette

    Joined:
    Apr 14, 2008
    Posts:
    143

    Wow man chillout...
     
  7. dreadt9

    dreadt9

    Joined:
    Jan 13, 2012
    Posts:
    143
    With? There is no sarcasm in the message if that is how you are reading it...
     
  8. NathanWarden

    NathanWarden

    Joined:
    Oct 4, 2005
    Posts:
    663
    Hey all,

    We did submit it to the asset store a few days ago. They found a few very small issues with it that have been addressed. So, we will be resubmitting it probably sometime today. :)
     
  9. dreadt9

    dreadt9

    Joined:
    Jan 13, 2012
    Posts:
    143
    Its out! It is now on the asset store for $100
     
  10. SteveB

    SteveB

    Joined:
    Jan 17, 2009
    Posts:
    1,448
    Methinks it would behoove you guys to get the docs, examples and tutorials online asap lest you have a similar response other AI software has suffered from enthusiastic customers... :)
     
  11. profcwalker

    profcwalker

    Joined:
    May 3, 2009
    Posts:
    243
    Hi Guys,

    We had to pull it down for just a bit. We'll resubmit tomorrow along with providing the tutorial videos and docs.

    And yes, I definitely agree SteveB. :)

    Thanks.
     
  12. pneill

    pneill

    Joined:
    Jan 21, 2007
    Posts:
    207
    Any chance this will hit the asset store by Friday? Would love the opportunity to experiment with it over the long weekend.
     
  13. profcwalker

    profcwalker

    Joined:
    May 3, 2009
    Posts:
    243
    @pneill: Yes, we should be re-submitting tomorrow. We also have about 1 1/2 hours of training videos completed to support it, taking you step by step through everything. :)
     
  14. nuverian

    nuverian

    Joined:
    Oct 3, 2011
    Posts:
    2,053
    This looks very interesting indeed. Any chance this could work with third party pathfinding in the future? (A* project, simplepath)
     
  15. profcwalker

    profcwalker

    Joined:
    May 3, 2009
    Posts:
    243
    @nuverian: Yes, it could certainly be tied in to other pathing tools (A* project, simplepath).

    Also, we have re-submitted the project. While we wait on it to be approved, I'm posting all our AI tutorial videos here (next post). We will have the videos available for viewing and download on our website this week.

    Let us know if you have any questions. Thanks.
     
  16. profcwalker

    profcwalker

    Joined:
    May 3, 2009
    Posts:
    243

    Introduction to AI Behaviors and Components










     
  17. profcwalker

    profcwalker

    Joined:
    May 3, 2009
    Posts:
    243

    AI States
    This set of video tutorials walks you step-by-step through setting up each state type.































     
    Last edited: May 25, 2012
  18. profcwalker

    profcwalker

    Joined:
    May 3, 2009
    Posts:
    243
    AI Behaviors
    Stringing different states together to create AI Behaviors





     
  19. appliquette

    appliquette

    Joined:
    Apr 14, 2008
    Posts:
    143
    Hi - sorry if this has already been answered but are there preset routines available?
    Ie. standard melee mob AI, ranged etc that already have the typical AI routines, rather than having to reinvent the wheel so to speak?
     
  20. profcwalker

    profcwalker

    Joined:
    May 3, 2009
    Posts:
    243
    @andrewo: Each state is already created (melee, ranged, idle, etc), you define how you would like your character to react within the states and what elements will trigger a change to the state.

    Also, you may want to watch the two videos right above here (Ai Behaviors). These illustrate the idea of stringing together several states.

    Let me know if I've answered the question for you. Thank you. :)
     
  21. WillModelForFood

    WillModelForFood

    Joined:
    Dec 5, 2011
    Posts:
    143
    This is amazing! Only concern I have is different heights, I mean if you make something simple like a ramp or anything at a different height will the pathfinding still work? What about something a little more advanced like a flying target?
     
    Last edited: May 25, 2012
  22. Mikie

    Mikie

    Joined:
    Dec 27, 2011
    Posts:
    367
    Looks great. Will it work with Indie?
     
  23. SteveB

    SteveB

    Joined:
    Jan 17, 2009
    Posts:
    1,448
    ...currently going through all the videos (yay), but a question arose...

    ...can you create randomization of states within a state so you can have variety in the animations? In other words, I have 4 melee attack anims, of which the the percentage chance would be:

    Attack 1 - 10%
    Attack 2 - 25%
    Attack 3 - 35%
    Attack 4 - 30%

    No doubt you'd want to have more than a single anim for the preset states you currently have. Idles alone would have several, including unique, rare fidget idles that play infrequently.


    ...secondly, what about new states altogether? Seek shelter? Flank, Go Prone, Find Higher Ground, etc?

    Thanks C :D

    -Steve
     
  24. rygaar

    rygaar

    Joined:
    Mar 28, 2009
    Posts:
    63
    Can you provide a video to demonstrate how this can be integrated with a different pathing solution?

    thanks
     
  25. bryanleister

    bryanleister

    Joined:
    Apr 28, 2009
    Posts:
    130
    This looks really great! What's the ETA for release? I have a project this week I've been putting off doing the AI in hopes of using this system. Seems like this will do what I need.

    One question, can I trigger state changes based on my own events? And, can I set up additional states fairly easily?

    Bryan
     
  26. shahab

    shahab

    Joined:
    Nov 28, 2011
    Posts:
    4
    Hi , I watched some of the movies , your package is really nice , I really need something like this :D
    I have a question : I have a character I want him to walk around the environment ( it can be achieve with patrol) but I want it to do some works between nodes , for example at first node he stay or sit for 1 or 2 minutes , at second node he change his animation and rotation , and at third node he do a random animation . can I make it work with your package?
    thanks in advance , have a nice day :)
     
  27. profcwalker

    profcwalker

    Joined:
    May 3, 2009
    Posts:
    243
    AI Behavior is now available on the Asset Store. Pick up your copy today. :)
     
  28. Mikie

    Mikie

    Joined:
    Dec 27, 2011
    Posts:
    367
    You don't seem to have the answer to my question. Does it work with the free version of Unity? All your demos are with the Black version.
     
  29. profcwalker

    profcwalker

    Joined:
    May 3, 2009
    Posts:
    243
    Hi Mikie,

    Yes, the free version of Unity will work with it. If you really want to benefit from it, you'll need pro for the NavMesh. The run-time NavMesh system actually works with Unity Free, but, it doesn't grant you the ability to bake the NavMeshes. Once they're baked it doesn't matter which version you use. We have baked in all example scene NavMesh so that you can experiment with those. Everything else works seamlessly between Free and Pro version.

    Let me know if you have further questions. Thank you.
     
  30. Mikie

    Mikie

    Joined:
    Dec 27, 2011
    Posts:
    367
    OK. About to buy. In you movies when you start with Navigation, I can use NavMesh? Do you have a movie on this?
     
  31. NathanWarden

    NathanWarden

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

    The answer is yes! :) It will require just a little bit of scripting on your part though, not much. You could put a trigger on the patrol point that detects when your AI agent enters it, then you can deactivate the AI and have him sit for 1 or 2 minutes or whatever you want it to do, then reactivate it. As long as you don't have a timer trigger setup for the patrol itself, it will resume the patrol state when it's reactivated.
     
  32. NathanWarden

    NathanWarden

    Joined:
    Oct 4, 2005
    Posts:
    663
    Hi Mikie, you can simply setup your nav meshes by checking the static box in the inspector, and then go to your Window/Navigation window and hit Bake. That's pretty much all there is to setting up a basic NavMesh.

    edit: If you have the Free version, you won't be able to do the baking process on your copy, you'll have to bake it using a pro version of Unity. The actual NavMesh will work under Unity Free, you just can't bake them.

    Hope this helps :)
     
    Last edited: May 29, 2012
  33. Mikie

    Mikie

    Joined:
    Dec 27, 2011
    Posts:
    367
    Hi Nathan,

    After I add the NavMesh, I get an error -- "Failed to create agent because there is no valid NavMesh". Isn't this a problem.
     
  34. NathanWarden

    NathanWarden

    Joined:
    Oct 4, 2005
    Posts:
    663
    Hi Bryan, we have yet to document the API, but yes, you can setup your own events and tell it to change to whatever state you'd like. It'll be something like this:

    AIBehavior ai = GetComponent<AIBehavior>();

    ai.ChangeState(AIBehavior.State.Patrol); // where AIBehavior.State is an enumeration of the builtin states

    or

    ai.ChangeState(patrolState); // where patrolState was grabbed from the ai object

    or

    ai.ChangeState(myCustomState); // where myCustomState is a state object that derives from BaseState


    Please let me know if you need additional clarification :)
     
  35. NathanWarden

    NathanWarden

    Joined:
    Oct 4, 2005
    Posts:
    663
    Hi Mikie, is this giving you this error in one of the sample scenes, or in a new scene?
     
  36. Mikie

    Mikie

    Joined:
    Dec 27, 2011
    Posts:
    367
    New scene.
     
  37. rygaar

    rygaar

    Joined:
    Mar 28, 2009
    Posts:
    63
    Can you provide a information or a demonstration on how this can be integrated with a different pathing solution, e.g. SimplePath, xaitMap? Or is the product only geared towards the built in unity pro navmesh solution?
     
  38. NathanWarden

    NathanWarden

    Joined:
    Oct 4, 2005
    Posts:
    663
    Hi Mikie, if you open up one of the example scenes and try it out it will work. The problem you're having is that in a new scene you must bake a nav mesh before the NavMeshAgent will work.
     
  39. NathanWarden

    NathanWarden

    Joined:
    Oct 4, 2005
    Posts:
    663
    Hi rygaar, for now it only works with the builtin NavMesh system. I'll probably have a chat with the guys tonight about supporting any Nav system out there, although it will require more code setup on the user's end if not using the builtin version.
     
  40. Mikie

    Mikie

    Joined:
    Dec 27, 2011
    Posts:
    367
    Nathan, I don't have AI Behaviors yet. Is there anyplace I can get a NavMesh(baked)? Thanks.
     
  41. NathanWarden

    NathanWarden

    Joined:
    Oct 4, 2005
    Posts:
    663
    You'd need to be on a team or have a friend with Unity Pro. However, last night I went ahead and added support for external pathfinding tools. So, you'll be able to use 3rd party systems like the free Path system from Angry Ant. This will be available for the next release which will hopefully be by the end of the week along with some other fixes.
     
  42. bryanleister

    bryanleister

    Joined:
    Apr 28, 2009
    Posts:
    130
    Can you explain the function and purpose of the General AI properties Raycast Layers? It seems like the Player Tags above would be checking for a player tagged 'Player' for example. And, if that player is on the Player layer, then Raycast would naturally want to be looking for it there.

    However, I found that in order for the Follow script to actually turn and move towards the Player, I needed to uncheck the Player layer from Raycast Layers. I noticed you did this in the video very quickly, and left that layer unchecked in the examples leaving the Raycast Layers mixed, with Player unchecked.

    If I set the Raycast Layers to Everything in your complete avatar, he will move but not rotate towards the player. This seems the opposite, that I should have it checking the Players layer using Raycast, but seems like I need to tell it to NOT check that Layer...
     
  43. NathanWarden

    NathanWarden

    Joined:
    Oct 4, 2005
    Posts:
    663
    Hi Bryan, great question!

    Quick answer: Raycasts are for detecting obstacles between the Player and the AI.

    Longer answer: The raycast layers are for detecting objects between the Player and the AI, so if the Player layer was the only one checked and has a collider on it, it will see that something was hit and assumes there's something between the AI and the Player. Thus, you want to ignore the player's collider and only detect if the raycast hit a wall or some other obstacle.
     
  44. bryanleister

    bryanleister

    Joined:
    Apr 28, 2009
    Posts:
    130
    Thanks, that makes sense. Just getting into this and it's a fun system. It takes getting used to how to program states that make sense, having an editor like this makes it fun to try out different state change ideas.

    One question, or refinement that would be nice. In the Patrol state, the only rotation option is to change the rotation speed, it would be nice to trigger a pivot or turning animation so the character doesn't have that sliding feeling as it turns.

    Could I use Node Action to do this? He reaches the node, then pauses, pivots to face the next node and then resumes the patrol. My character has a turn right and turn left animation that could be used for this type of movement.
     
  45. Mikie

    Mikie

    Joined:
    Dec 27, 2011
    Posts:
    367
    Nathan, I have A* Pathfinding working on my Antroid. Will this work with the mode you are making with AI Behaviors. I can hardly wait. Friday??/
     
  46. NathanWarden

    NathanWarden

    Joined:
    Oct 4, 2005
    Posts:
    663
    We will definitely take this into consideration with the next major "dot" release, I agree that this will definitely make it work smoother. We will also be opening up some API stuff so that you can do some more custom stuff with it.

    Also, I've fixed the bug you sent us in your bug report already, thanks a ton for sending it! :)
     
  47. NathanWarden

    NathanWarden

    Joined:
    Oct 4, 2005
    Posts:
    663
    Awesome, it more than likely will work with it. How I've set it up is that there is a callback that gives you a target position, a speed at which the ai agent should go, and a rotation speed. The most important of those is the target position, of course. So as long as the pathfinding system you have works with passing it a Vector3 or a Transform as a target it will work with it :)

    It will more than likely be available Friday or Monday depending on how long the acceptance of our update takes.
     
  48. danreid70

    danreid70

    Joined:
    Aug 28, 2010
    Posts:
    224
    Ohboy... (or should I say "OhWalkerboys"?) -- Let me make sure I have this right... The only reason Pro is needed is for the NavMesh baking (which is only supported in Pro, not Indie) - but with the upcoming update, this new ability to use (for example) Angry Ant's Path, we can use this with Indie?! BLESS YOU GUYS!!! :) I've been following this thread wishing I could use it, but am not yet ready to take the Pro plunge (so far, Unity is just a hobby, and until I start making something worth selling, I'm staying with Indie - but spending a bundle in the Asset Store, so I feel better)... :)

    If it works with Path, you'll have another sale with the new release! :) I've been watching the tutorials whenever I get the chance and it looks AMAZING! Great job guys!
    --Dan
     
  49. bryanleister

    bryanleister

    Joined:
    Apr 28, 2009
    Posts:
    130
    Sweet! This worked easily, and I found some things in your scripts that got me going in the right direction. One thing I changed was to make the 'currentState' public so I could check what state the ai was in before changing to a new state. Really fun system, looking forward to writing up my own states as well.

    Bryan
     
  50. NathanWarden

    NathanWarden

    Joined:
    Oct 4, 2005
    Posts:
    663
    Awesome Bryan! Very happy to hear you're enjoying it. Getting the currentState will be public as of the new release which will probably be available Monday.

    You can also use a callback to get the state changes.

    Code (csharp):
    1. using UnityEngine;
    2. using System.Collections;
    3.  
    4. public class MyScript : MonoBehaviour
    5. {
    6.     void Awake()
    7.     {
    8.         AIBehaviors ai = GetComponent<AIBehaviors>();
    9.         ai.onStateChanged = OnStateChanged;
    10.     }
    11.  
    12.  
    13.     void OnStateChanged(BaseState newState, BaseState previousState)
    14.     {
    15.         Debug.Log("State changed to: " + newState.GetType().ToString());
    16.     }
    17. }
     
unityunity