Search Unity

Behavior Designer - Behavior Trees for Everyone

Discussion in 'Assets and Asset Store' started by opsive, Feb 10, 2014.

  1. MoHoe

    MoHoe

    Joined:
    Nov 5, 2012
    Posts:
    566
    If you don't mind me saying so Sir, I believe your plumbing is in tip top condition Sir.

    I bid you a good day :p
     
  2. Gronky

    Gronky

    Joined:
    Feb 26, 2014
    Posts:
    7
    hehe. It looks good. I will buy it and play. Though I will also need to buy that PlayMaker to have full out of body experience :)
     
  3. Gronky

    Gronky

    Joined:
    Feb 26, 2014
    Posts:
    7
    Because those behaviour trees look like XML structure this would be a good format to store them in. Also I wouldn't mind if tree's branches were collapsible (+/- buttons) in the editor (like you can do it for XML file in the web browser for example). Ah, when it comes to the format of that XML file, you could check out how CryEngine currently handles it (just a suggestion).
     
    Last edited: Feb 26, 2014
  4. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    4,739
    I submitted another bugfix earlier today. MoHoe, you'll get your gizmos with this version :)

    - Added Behavior Designer gizmos (can be disabled within the preferences)
    - Proper coroutine support within tasks
    - Bugfixes


    In addition, I (finally) finished uploading the videos that go over the sample projects. You can see them on the videos page.


    hah, awesome.

    Almost. To experience the full out of body experience, you need uScript as well. Just imagine creating a behavior tree that involves writing your own task, PlayMaker, and uScript. :)

    I could see how collapsible branches could be useful. The one thing that I am going to be careful about is to not clutter up the UI. If I can get it in cleanly then I'll add it. In terms of serialization, if everything is working correctly you should never have to see the raw serialization.
     
  5. SteveB

    SteveB

    Joined:
    Jan 17, 2009
    Posts:
    1,448
    It warms the cockles of my heart that MoHoe (fo' sho!) has properly handled your plumbing opsive, to be of his opinion that it is indeed in top-condition. :D
     
  6. Seith

    Seith

    Joined:
    Nov 3, 2012
    Posts:
    725
    @Opsive: I use the Event System for Mecanim (http://forum.unity3d.com/threads/163731-Event-system-for-Mecanim) asset which allows for functions to be called at certain points in an animation state. Which is really great and so much better than Unity's default event system (which is linked to a specific animation clip). The problem is it's looking for functions in MonoBehavior scripts to execute events, not BT tasks scripts.

    So here's my question for you: is there a way for a specific function within a task to be executed by a MonoBehavior script? Right now I have to keep a MonoBehavior buffer script that contains a boolean variable which is triggered by my event function while my task is listening to that script's boolean (in the OnUpdate function) and THEN executing the "real" event function within the task. That's quite messy and I would love for the event system to be able to trigger the function directly within the task file.

    Is that something that could become possible with the blackboard feature you're working on? Or is it already feasible now maybe?
     
  7. Gronky

    Gronky

    Joined:
    Feb 26, 2014
    Posts:
    7
    I was considering it and Vizio (Universe) as well but I'm a programmer so where PlayMaker will help me do many simple tasks fast and easy, uScript may just slow me down. I don't feel like I need replacement for code but rather plumbing tools so I can just concentrate on gameplay AI. For now my list consist of BD, PM and A* Pathfinding Project. This list will most likely grow if I actually find it fun to create games on Unity platform. I'm not new to programming but fresh to Unity and games. Also I haven't read too many good things about uScript, unfortunately.
     
  8. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    4,739
    @Seith -

    I don't think the blackboard feature will help you much in that regard. You'd still have to poll a bool variable within the OnUpdate function.

    I can think of two solutions. The first one is to ask the developer of Event System for Mecanim to support ScriptableObject to execute the events on. If you could call an event on a ScriptableObject you would then be able to use a task for a callback instead of having an intermediary MonoBehaviour component. MonoBehaviour and ScriptableObjects are very similar so it shouldn't take much work for the Event System developer. If the developer needs help from me for any reason I don't mind helping.

    The other solution still involves an intermediary MonoBehaviour component, but it will get rid of having to poll a variable within OnUpdate. Your intermediary MonoBehaviour component would look something like:

    Code (csharp):
    1.  
    2. public class MecanimEvent : MonoBehaviour {
    3.  
    4.     public delegate void MecanimEventHandler();
    5.     public event MecanimEventHandler onMecanimEvent;
    6.  
    7.     public void mecanimEventCallback()
    8.     {
    9.         if (onMecanimEvent != null) {
    10.             onMecanimEvent();
    11.         }
    12.     }
    13. }
    14.  
    Then your task would subscribe to that mecanim event:
    Code (csharp):
    1.  
    2. public class MecanimTask : Action
    3. {
    4.     public override void OnAwake()
    5.     {
    6.         var mecanimEvent = gameObject.GetComponent<MecanimEvent>();
    7.         mecanimEvent.onMecanimEvent += taskMecanimEventCallback;
    8.     }
    9.  
    10.     public void taskMecanimEventCallback()
    11.     {
    12.  
    13.     }
    14. }
    15.  
    Now you'll no longer have to poll the variable within onUpdate.
     
    Last edited: Feb 27, 2014
  9. MoHoe

    MoHoe

    Joined:
    Nov 5, 2012
    Posts:
    566
    "I submitted another bugfix earlier today. MoHoe, you'll get your gizmos with this version "

    whooooot!!! :) nice work

    "In addition, I (finally) finished uploading the videos that go over the sample projects. You can see them on the videos page."

    Top man, very nice indeed :)

    "It warms the cockles of my heart that MoHoe (fo' sho!) has properly handled your plumbing opsive, to be of his opinion that it is indeed in top-condition. "

    hehehe :p
     
  10. Seith

    Seith

    Joined:
    Nov 3, 2012
    Posts:
    725
    @Opsive: Thanks you, I tried using the code you provided but for some reason I didn't manage to get it to work (my fault without a doubt). So I'll just keep using my current method. I'll contact the Mecanim Event System creator though and ask him about adding support for ScriptableObjects...
     
  11. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    4,739
    I am getting one step closer to being able to release the runtime source code. On the Behavior Designer page I added a PayPal link that you can now purchase through. If you use PayPal you'll receive a download code instantly, with the added benefit that the updates don't need to go through review and I'll send an email whenever a new update is released.

    @Seith -

    If you want any help feel free to post or PM me some code to look at. Getting the events to work is a lot cleaner than having to poll a variable for a change.
     
  12. ojuzu

    ojuzu

    Joined:
    Jun 29, 2006
    Posts:
    64
    Hello opsive. I purchased this a couple of days ago and so far it looks like the best BT solution on the store. But a couple of related issues/questions have come up for me.

    Firstly, when I use the External Behavior Tree task, I'm curious where that new BT lives? It's not being added to the gameobject that contains the initial BT and it doesn't appear to be replacing the current behavior. I did notice that there's a generic BehaviorManager object in the scene during runtime. Is that where it is?

    That leads to my second question: If I want to reference a variable or callback from a component on the original gameobject in the external behavior, how should I do that? For example, I'm using an A* grid that gives me a callback once the AI has reached its target. I need to let a task in this secondary BT know that the AI has reached its target but I have no idea where this BT is in the scene and therefore how to reference it. Does that make sense? What would be the most reliable way to update the task in this scenario?

    Thanks in advance for any help!

    Dennis
     
  13. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    4,739
    Hi Dennis,

    Thanks for your purchase, happy to hear that you're enjoying it so far.

    When any BT starts up it registers itself with the Behavior Manager. The Behavior Manager manages all of the different behavior trees that are within your scene. Each task still lives on the game object that you assigned the behavior tree component to - the Behavior Manager just determines what tasks should be executed when.

    In the case of the external behavior tree, when that external behavior tree is loaded it is loaded onto the game object that has the behavior tree component with the external behavior tree task. In the case of your second question, if you want to reference a variable or callback from a component on the original game object then you can pretty much pretend like the external tasks are on that game object. For example, let's say that you have a game object that has the NavMeshAgent component added to it. You also have a behavior tree added to it that calls an external behavior tree. Within those tasks of that external behavior tree you can call gameObject.GetComponent<NavMeshAgent>() and the NavMeshAgent component will be found.

    Does that make sense?
     
  14. SteveB

    SteveB

    Joined:
    Jan 17, 2009
    Posts:
    1,448
    You know I have to ask this, risking revealing myself as even more ignorant than I try to let on...

    ...but I'm an avid Playmaker user, and I'd like to believe I understand FSM's as I use them daily.

    I've read as much as I could stand to on BT's vs. FSM's in large and frightening non-Unity interwebs, but I can't help but come to the conclusion that BT's are truly only useful for AI's. That's perfectly fine, but are there other uses that would make it ideal over Playmaker? I've code my own (rudimentary) gameplay AI (patrol/chase/attack) and I could duplicate and expand upon it easily in Playmaker.

    I do understand that BT's are more flexible, and easier to grow and maintain, being able to more simply add additional behavior to and existing tree without having to potentially rewire as much as I would with an FSM.

    So I guess that is pretty much the crux of it...why a BT and not Playmaker? Why am I so compelled by this tool yet equally at a loss as to what to use it for?!? Haha...

    Thanks!

    -Steven
     
  15. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    4,739
    Hah, I like it.

    The question doesn't have to be why a BT and why not a FSM. The question should instead be why use a BT and a FSM together. They aren't mutually exclusive. You are right- BTs are mostly used for AI. You could use them for a dialog tree like you asked earlier but you could also use a FSM for that. A BT is probably overkill for a dialog tree (that doesn't mean it won't work, that just means there are a lot of task types that you'd never need with a dialog tree).

    One of the BT advantages that you mentioned is flexibility. In PlayMaker how would you run two different states at once? That's actually a legitimate question because I don't know how you would besides creating two separate FSMs. With a BT all you need to do is add the parallel task as the parent and there you have it, both child tasks will be running at the same time. You could then combine that with PlayMaker and have two PlayMaker FSMs running at the same time. Then lets say that you have a third task also running in parallel and it detects a condition where it needs to stop both of the PlayMaker tasks from running for some reason. All you need to do is add an interrupt task and that third task will be able to end the other two tasks immediately. In addition, lets say that you have two different tasks that play an animation. You don't want both tasks to play at the same time because the animation affects the same bones and it would look weird if both animations were playing at once. With a behavior tree, you can add a semaphore (called a task guard in behavior designer) and it will only allow one animation task to play at a time. When the first one finishes the second one will start.

    In my mind BTs are more dynamic than FSMs are. It is quicker to create a BT that will adopt to all sort of situations whereas it would take a lot of states with a FSM in order to come up with that exact situation. But like I said at the start - joining Behavior Designer with PlayMaker is where the true magic happens. You could use PlayMaker for all of the condition/action tasks and Behavior Designer for the composite/decorator tasks. If you used this method you'd be playing off of each others strengths. The flexibility of a BT and the power of a FSM.
     
  16. ojuzu

    ojuzu

    Joined:
    Jun 29, 2006
    Posts:
    64
    This does make sense, thanks for explaining. The thing that was/is confusing me is that I was not able to actually find the external behavior tree anywhere in the scene. The Behavior on my gameobject is still showing the original BT as the active BT and not the externally loaded BT prefab it spawned. I'll take a look again make sure I'm not missing something.

    Thanks for the clarification!

    BTW, I saw earlier in the thread that you were going to be including a system to hold variables in the Behavior Manager so we wouldn't need to use a blackboard. That will be great! Any ETA for that?
     
  17. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    4,739
    Yeah, so the external tree is there but you won't be able to see it in the editor while in play mode. When any tasks are running within the external behavior tree just the external behavior tree task will light up and you won't be able to see the actual tasks within the editor window. That's one feature that I had to cut for version 1.0 and I plan on adding it later.

    The blackboard feature is what I am working on next. I was planning on starting on it towards the end of the week but other things ended up getting in the way. I don't have an ETA because I don't know how long it'll take but it will be my highest priority.
     
    haikezhijian likes this.
  18. SteveB

    SteveB

    Joined:
    Jan 17, 2009
    Posts:
    1,448
    Great sell opsive...I like it! :D

    You know I did frame the question as 'either-or' rather than both, so I concede my wording wasn't the best for my question. I did actually forget a strong selling point for BeDesigner is your PM/uScript integration, which in turn is rather genius now that I've had this exchange with you. :D

    But yea, simply mentioning simultaneous states is a big one. With an FSM you'd have to have separate FSM's or at the very least call several states in an FSM in one frame, but even that I'm unsure if that would work...

    ...well I appreciate you taking the time. I feel that much (/me holds fingers a tiny bit apart) less ignorant, and for that...

    ...I thank you with a purchase!

    Cheers man

    -Steven
     
  19. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    4,739
    I appreciate it! I'll be curious if you ever find a use for it :)
     
  20. SteveB

    SteveB

    Joined:
    Jan 17, 2009
    Posts:
    1,448
    I'll be as well!

    Haha, after going through your base BD samples, it all was far clearer to me, and I'm about to go through the Playmaker sample, feeling pretty good now about how this can all work for me. The custom behaviors is where it's at, and yea moreso with Playmaker as you can make these tiny encapsulated FSM's to call just like you would any custom coded action.

    Thanks again opsive!

    -Steven
     
  21. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    4,739
    The runtime source code version is now available on the Behavior Designer page. It will include the source code for every class under the "Behavior Designer/Runtime" directory. The editor still has a DLL.

    I still need to add the code to allow you to take the price difference if you've already purchased the non-source code version.

    Also, based on our discussion with SteveB yesterday I added a new topic to the documentation: behavior trees or finite state machines.
     
    Last edited: Mar 2, 2014
  22. Vectrex

    Vectrex

    Joined:
    Oct 31, 2009
    Posts:
    204
  23. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    4,739
    Appreciate it. Can you expand on what you mean when you say that it is more frustrating to integrate? Is it just because you have to create all of the conditional/action nodes and the basics aren't already created? Also, the runtime source is available, it is just a more expensive version and you have to purchase it with paypal instead of through the asset store.

    Looking at that list nothing seems too out of reach. For the interrupt one you can see which node it is connected to by selecting the perform interruption task, go to the task inspector, and click on the "i" next to the interrupt task name. Yeah it is no substitute for having a visual way without clicking on the "i". I'll work on it.

    Can you expand more on the easier way to reorganize tasks?

    The biggest one is probably adding more conditional/action tasks. I want to finish the editor features first (such as a blackboard) and then I'll start adding more tasks.
     
    Last edited: Mar 3, 2014
  24. ojuzu

    ojuzu

    Joined:
    Jun 29, 2006
    Posts:
    64
    opsive: All is working well for the most part but I get the occasional glitch where the BT editor gives an error stating it can't load and it goes into an infinite error loop unitl it times out. Then I shutdown Unity and restart it's fine again. Have you seen anything like this? I'm just curious if it's a known issue. If not, then I'll take some screenshots and send them to you.

    Thanks!

    Dennis
     
  25. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    4,739
    I have not seen that bug. Is it reproducible? I have fixed a fair number of bugs (mostly related to prefabs) and version 1.0.2 is still waiting to be approved. I'll PM you the latest to see if it already happens to be fixed.
     
  26. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    4,739
    Behavior Designer 1.0.2 has been approved. It addresses the following:

    - Added Behavior Designer gizmos (can be disabled within the preferences)
    - Proper coroutine support within tasks
    - Bugfixes

    Most of the bugfixes relate to prefabs. I think that I'll only have one more bugfix update before version 1.1. In the meantime, I've been working on adding the blackboard feature to the editor. You'll be able to add new variables like so (the GUI is still a work in progress):

    $variables.PNG
     
  27. lfdl2401Studios

    lfdl2401Studios

    Joined:
    Mar 4, 2012
    Posts:
    12
    @opsive AI looks great I just have a few questions:
    1. Does Behavior Designer use Unity’s Navmesh (or anything similar) to make the AI navigate the scene?
    2. If not, are there plans of implementing Navmesh?
    3. How does it avoid obstacles or getting stuck on objects?
     
  28. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    4,739
    Hi lfdl2401Studios,

    Thanks for taking a look at it.

    1. The CTF and RTS scenes do use Unity's Navmesh. If you download those sample projects you can see the code for those tasks that use the Navmesh. However, this asset is more true to a behavior tree solution rather than a pathfinding solution. If you are looking to create your own AI using a behavior tree (by writing your own tasks, using PlayMaker, or uScript) then this asset is for you. If however you are looking for something that will only give you pathfinding then this probably isn't the asset for you. You can definitely do pathfinding with this asset, but behavior trees open the world to so much more than just pathfinding. I wasn't sure which way you were leaning by your questions.

    3. It doesn't. The tasks provided are more meant to show how to use the behavior tree implementation, rather than being a pathfinding solution. It wouldn't be hard to add those features but that isn't the focus of the sample projects.

    In the future I may create more tasks or whole projects that use Behavior Designer for pathfinding, but currently Behavior Designer is strictly a behavior tree implementation.

    Justin
     
    Last edited: Mar 5, 2014
  29. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    4,739
    Version 1.0.3 has been submitted to the Asset Store. It just contains a few bug fixes. If you purchased Behavior Designer through PayPal you should have already received an email (except if you purchased the runtime source, that version was already up to date)

    I have been working on adding the visual blackboard and I have to say that it is really going to make creating blackboard variables a lot easier. Here's an example:

    Lets say that I want to have two tasks share an int variable. In the past I would have to create a separate MonoBehaviour component and add it to the game object that the behavior tree is on. Within that component I would have a single int variable that the tasks can then access by doing:
    Code (csharp):
    1.  
    2. GetComponent<MyBlackboard>().IntVariable
    3.  
    In the sample scenes we store a reference to the blackboard variable so we can quickly access that component.

    That was the past. Now all you need to do is create a new int within the variables tab of Behavior Designer:

    $Variables.PNG

    To reference that variable within a task you create a new variable of type SharedInt:
    Code (csharp):
    1.  
    2. public class SharedVariableTask : Action
    3. {
    4.     public SharedInt sharedInt;
    5.  
    Then within the task inspector you assign that int:

    $SharedInt.PNG

    That is all it takes. Now to share values all you have to do is reference the same variable from the blackboard. For example, I have the following tree:

    $tree.PNG

    SharedVariableTask looks like:
    Code (csharp):
    1.  
    2. public class SharedVariableTask : Action
    3. {
    4.     public SharedInt sharedInt;
    5.  
    6.     public override void OnAwake()
    7.     {
    8.         Debug.Log("Awake Value: " + sharedInt.Value);
    9.     }
    10.  
    11.     public override TaskStatus OnUpdate()
    12.     {
    13.         sharedInt.Value += 12;
    14.         Debug.Log("OnUpdate: " + sharedInt.Value);
    15.         return TaskStatus.Success;
    16.     }
    17. }
    18.  
    When the tree starts I expect both tasks to output a value of 39 since that is the value that I set IntVariable to within Behavior Designer. The first task will run and output a value of 51 since 12 was added to it. By the time it gets to the second task I expect it to output a value of 63 since it should have started with a value of 51. And that is exactly what happens:

    $output.PNG

    Because of these variables I am going to be deprecating three task attributes: SharedField, SynchronizedField, and LinkedTask. Variables have all of the functionality of these attributes in addition to providing a lot more functionality.

    Let me know if you'd like to help test this new feature. I'd like to get a couple of people to tell me what I did wrong before I submit version 1.1 to the asset store (I still have a few more things planned for 1.1).
     
    Last edited: Mar 6, 2014
  30. ojuzu

    ojuzu

    Joined:
    Jun 29, 2006
    Posts:
    64
    This looks great. I'm looking forward to it!
     
  31. Silly_Rollo

    Silly_Rollo

    Joined:
    Dec 21, 2012
    Posts:
    486
    Looks great. Are the types modifiable or is it limited to standard Unity types?
     
  32. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    4,739
    You won't be able to create your own SharedVariables but I have come up with a pretty good list. One of those include UnityEngine.Object so pretty much anything falls under that.

    The types are:

    SharedBool
    SharedColor
    SharedFloat
    SharedGameObject
    SharedInt
    SharedObject
    SharedQuaternion
    SharedRect
    SharedString
    SharedTransform
    SharedVector2
    SharedVector3
    SharedVector4
     
  33. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    4,739
    I forgot to post this yesterday: Behavior Designer 1.0.3 has been approved and is on the Asset Store. This should be the last bugfix release before version 1.1. The price is going to go up with version 1.1.

    - Serialization fixes
    - Renamed “link” to “reference” when referencing other tasks within the graph
     
  34. Seith

    Seith

    Joined:
    Nov 3, 2012
    Posts:
    725
    @Opsive: Just a simple question: How do I disable/enable a BehaviorTree component via code? I tried a:

    Code (csharp):
    1. guardTransform.GetComponent<BehaviorTree>().enabled = false;
    But that doesn't work; I get an error message saying: The type or namespace name `BehaviorTree' could not be found. Are you missing a using directive or an assembly reference?

    I'm sure it's a very simple thing to do but I'm stumped... :(
     
  35. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    4,739
    Make sure you include the BehaviorDesigner.Runtime namespace:

    Code (csharp):
    1.  
    2. using BehaviorDesigner.Runtime
    3.  
    4. public class MyClass : MonoBehaviour {
    5. ...
    6.    guardTransform.GetComponent<BehaviorTree>().enabled = false;
    7. ...
    8. }
    9.  
    If you are enabling it, if BehaviorTree.startWhenEnabled is true then it will start automatically. If it is not you can manually start it with BehaviorTree.enableBehavior(). You can manually disable/pause it with disableBehavior(bool pause).
     
  36. Seith

    Seith

    Joined:
    Nov 3, 2012
    Posts:
    725
    Thank you Opsive, that works great!
     
  37. eagleeyez

    eagleeyez

    Joined:
    Mar 21, 2013
    Posts:
    364
    HI there,
    I am still trying to grasp the concept of using PlayMaker and Behavior Designer together and have been trying to work out what you did in the PM tutorial. It would be great if you could do a real tutorial instead of just showing a finished product. What I mean is a small project from start to finish, explaining why you are using certain things like inverters and so on in certain situations. Your videos could be in quality a little better. Use better capture software like MovAvi and you’ll get crisp HD without having to convert for YouTube. Your video are also not tutorials, they are showing stuff that is done. It is bit like me showing you someone flying an airplane. You can grasp what he is doing to fly the plane but in the end you’ll still not be able to fly it yourself.
    Getting back to a question about your PM example project. In the FSM is player in sight, how does the Dot product work? Why do I compare to -1 is insight.
    Anyway thanks, this BD is looking very interesting. Keep up the good work and if you keep making tutorials you will get lots of sales and don’t forget us PM people.

    EDIT2:
    1. How does the rocket move in your PlayMaker example when it gets created?
    2. How do the Explosion particles get called? I can’t find any call to Explosion.
    3. In Grenade I see Add force but in fire rocket I see no means of how the rocket moves.
     
    Last edited: Mar 9, 2014
  38. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    4,739
    Hi eagleeyez,

    I am using Camtasia Recorder for screen capture - it looks blurry on your end? This is going to sound stupid, but is the YouTube video's quality set to HD? In terms of the tutorial content, that is a good point. In the project overview videos I tried to explain why the behavior tree is setup the way that it is but I can definitely see needing more videos explaining how behavior trees work and the reason things are the way they are. When version 1.1 is release I am going to be recreating a few of those videos because things will change without needing the blackboard class anymore and I'll try to do a better job of explaining the behavior tree. When I come up with a good example of creating a behavior tree from scratch I'll create a video on that as well.

    In terms of your questions:

    1. The dot product basically compares the angle between two different vectors. If the dot product returns 1 it means two vectors are facing in the same direction. If the dot product returns -1 it means the two vectors are facing in opposite directions. A value of 0 means the two vectors are perpendicular to each other. In the case of the PM sample project, we are using the dot product to determine if the turret is facing the player. If the turret is facing the player then the two vectors will be in opposite direction, thus return a dot product of -1.
    2. The rocket has a move towards action added to it, which is the first state that it is in:
    $MoveTowards.PNG
    3. Take a look at the "Explode" state within the grenade. The second action that gets called is to create the explosion object:
    $explosion.PNG
    4. The grenade just gets one initial force added to it with AddForce but the rocket continuously tracks the player with move towards. This relates to number 2.

    Does that help at all? I'll try to come up with some videos that show the process of creating a behavior tree.

    Justin
     
  39. eagleeyez

    eagleeyez

    Joined:
    Mar 21, 2013
    Posts:
    364
    Wow! Thanks, the answers helped me a lot. It's actualy easy when you know how and why.
    Oh, and yes my Youtube is set to HD.
     
  40. eagleeyez

    eagleeyez

    Joined:
    Mar 21, 2013
    Posts:
    364
    Hi again,
    Another quick and stupid question. In the PM demo, where is the aiming cross hair to be found? I thought it would be at shot point on the CC or on the camera.
     
  41. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    4,739
    You mean where does it actually fire? It is in the First Person Controller FSM:

    $fire.PNG

    If you are asking where is the actual crosshairs then that is on a second orthographic camera named "Camera". It has a child GameObject named plane that has the actual crosshairs texture. (I admit my naming could be better.. I am going to need to update these sample projects with the 1.1 release so I'll name that camera better in that update)
     
  42. eagleeyez

    eagleeyez

    Joined:
    Mar 21, 2013
    Posts:
    364
    Thank you for the quick answer. I have written you a review. This is what I wrote.

    I have now understood the thinking and purpose behind this plugin and can only say, that this is just going to be indispensable for Unity and I now also understand how using Playmaker without this plugin would be just plain insane. The prise will go up soon as the developer mentions on his website, so do yourself a favour and get it before you regret it. The developer is very responsive and has promised more video tutorials and explanations in the future. It is easy for most people to understand quickly. I however needed a little more time as my brain hates logic that can go in many directions but I can assure you now my brain has now grasped this fantastic system. I can see lots of possibilities now, that I before never thought I would be able to do with Unity and Playmaker. Have fun with it and you will.
    My scale on this product-
    - Plugin Usability and Layout 10 / 10
    - Documentation 8 / 10
    - Video Tutorials 8 / 10
    - Getting started and Integration explanations 8 / 10
    - Contact and Forum 10 / 10
    - Prise value for money 10 / 10
    - Stability 10 / 10
    - Simplicity and Workflow 10 / 10
    - Preferences and settings 8 / 10

    Hope that helps some of you.
     
  43. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    4,739
    Awesome, thanks for leaving a review. I'll see what I can do to get those doc related topics up to a 10 :)
     
  44. PrisonerOfLies

    PrisonerOfLies

    Joined:
    Dec 6, 2013
    Posts:
    105
    looks very promising, any idea when the launch price will end ?
     
  45. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    4,739
    I will hopefully be able to submit version 1.1 this week and with that I am going to set the price to somewhere around $70. Eventually I'll set it to the full price of $95.
     
  46. PrisonerOfLies

    PrisonerOfLies

    Joined:
    Dec 6, 2013
    Posts:
    105
    will it integrate nicely with aaron astar pathfinding, or anyone who had done that ? :p
     
  47. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    4,739
    I haven't used that asset but after looking at the doc there shouldn't be a reason why you can't create new tasks that use the Aaron A* Pathfinding API. The CTF/RTS sample projects use Unity's NavMesh pathfinding but that asset's API looks similar.
     
  48. Stardog

    Stardog

    Joined:
    Jun 28, 2010
    Posts:
    1,434
    I don't totally get how BT's work. If we return TaskStatus.Running it locks into that action and won't check a previous condition in the sequence, so what's the clean way to break out of it? Just a lot of interrupts all over the place? For example, how do we make Wait task return failure part-way through?

    Suggestions:
    • It would be nice to have a Small Mode that uses 16x16 icons and a smaller font. The icons could be to the left of the text to make it even smaller still.
    • Colour coding (customisable in preferences, please). At least four colours for Actions/Composites/Conditions/Decorators would be nice.
    • Task atrribute for categories, e.g. [TaskCategory("Navigation")], so they show in a new collapsable inside Actions > Nav, etc.
    • Documentation descriptions of nodes in the BD inspector.
    • Optional horizontal view where tasks run top-to-bottom instead of left-to-right.
     
    Last edited: Mar 13, 2014
  49. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    4,739
    Hi Stardog,

    In the wait case, yes, using an interrupt is the only way to break out of it. Alternatively you could create a new task that has a timer in addition to the condition that you want to check that way you don't need to use an interrupt task.

    Thanks for the suggestions, they are all good ones. I am submitting version 1.1 tomorrow which is mostly new runtime features and I plan on version 1.2 being editor focused. I did add one editor-related feature from your list though -

    $categories.PNG

    I'll make a post within the next day or so that will go over all of the new features.
     
    Last edited: Mar 13, 2014
  50. Pyromuffin

    Pyromuffin

    Joined:
    Aug 5, 2012
    Posts:
    78
    Cool plugin! I'm having a decent time using it so far. I've got a few comments:

    1) Not having source is kind of a pain. There are some limitations in the editor that I will discuss below, that I'd like to take a stab at fixing, but without source, it's not possible. And, I can't really justify the increased cost of the source version.

    2) you can't reference tasks of derived types. For example, mySpecializedAction inherits from Action and has a few extra virtual parameters that I'd like. doASpecializedAction inherits from mySpecializedAction and has a concrete implementation, I have another task that has a public field for a mySpecializedAction reference, because it wants to do something with a mySpecializedAction. In this task, I can't select doASpecializedAction because well, it's not exactly a mySpecializedAction... but it does inherit from it. This seems like a limitation that makes it so I can't create modular tasks that do a certain thing and have other tasks that know how to handle them, regardless of their specific implementations.

    3) I already mentioned the thing about multiple classes in the same file crashing behavior designer on twitter, apparently this is a ScriptableObject limitation. That's fine.

    4) I can't figure out what the point of saving a behavior tree to a prefab is. Is there a way to dynamically load a behavior tree from a prefab at runtime? I've played around with Behavior.load, and it kind of works, though only for first gameobject that loads the tree, the subsequent gameobjects that load the tree don't do anything at all. I think this has something to do with the behavior manager's enableBehavior function loading up all the relevant GameObject components only the first time. Might have to do a little more digging on this.

    5) Along with number 4, I don't want to have multiple behavior tree components cluttering up a gameobject if I am just going to be using them one at a time, I'd like a way to just have one behavior tree component and load them dynamically based on game logic (perhaps from prefabs?).

    6) referenced tasks aren't indicated clearly enough, my suggestion for a quick fix to this is just have them highlighted in orange by default, and not have to click the little icon to get them to show up.

    I know I said a lot of things, but you've really done a great job, I don't want to diminish what you've already accomplished. Thanks for the great asset.
     
unityunity