Search Unity

AI: Behaviour trees in Unity: Behave 1.1 released

Discussion in 'Assets and Asset Store' started by AngryAnt, Sep 29, 2010.

  1. AngryAnt

    AngryAnt

    Keyboard Operator

    Joined:
    Oct 25, 2005
    Posts:
    3,045
    Thanks. I'll look into what I can do with colouring those icons :)
     
  2. AngryAnt

    AngryAnt

    Keyboard Operator

    Joined:
    Oct 25, 2005
    Posts:
    3,045
  3. BuildABurgerBurg

    BuildABurgerBurg

    Joined:
    Nov 5, 2012
    Posts:
    566
    I now Knight you AwesomeAnt !

    oh just one little thing, can you make a little youtube video showing how to use it?

    Thanks AwesomeAnt

    Edit.

    Purchased!!
     
    Last edited: Aug 29, 2013
  4. skalev

    skalev

    Joined:
    Feb 16, 2012
    Posts:
    264
    Hi Emil, can you add the actual trees into the example, and not just the compiled library?

    I see a Behaviours.asset file, but cannot open it with the interface.
     
  5. AngryAnt

    AngryAnt

    Keyboard Operator

    Joined:
    Oct 25, 2005
    Posts:
    3,045
    @skalev:
    Editing the full tree I can't really do without opening up the whole thing for free though. I'll see about more videos though.

    @MoHoe:
    That is an excellent idea. I'll work on that for sure :)
     
  6. atmuc

    atmuc

    Joined:
    Feb 28, 2011
    Posts:
    1,162
    in this link http://angryant.com/2013/08/25/Behave-2-0/ video has problem. after "Update: An introductory video to Behave 2 is now available:" i see "no video supported format and MIME type found".

    is %50 off launch price $100 ?
     
  7. AngryAnt

    AngryAnt

    Keyboard Operator

    Joined:
    Oct 25, 2005
    Posts:
    3,045
    Oh sorry. It's a Quicktime movie. What is your browser / OS combo?

    The launch price is indeed $100.
     
  8. skalev

    skalev

    Joined:
    Feb 16, 2012
    Posts:
    264
    So a bit off topic, but I'm really curious how you changed this icon around.

    $behaveicon.jpg

    I have some custom assets I've made, and I know if I change the icon on the script via the inspector, the assets will have that icon too. I can see the change happening in the meta files, but since you don't use them, thought you can maybe shed some light on this. (saw some other questions about it in the forums, so it will be great to get an "Insider's" answer).
     
  9. Abl4ze

    Abl4ze

    Joined:
    Sep 6, 2013
    Posts:
    3
    Hello Emil,

    we are currently in the progress of upgrading our project from Bahave 1.4 to Behave 2.0.
    We already used your Behave 1.4 framework, and converted our library as described in the readme-file.
    But we are still facing some issues.
    For instance we are not able to use the debugger, is there something special you need to do, to be able to use it?
    Furthermore we have quite some decorators in use, as they are now deprecated, how are we supposed to replace them?
    We looked for both problems in your documentation, but unfortunately were not able to find a solution there.

    Thank you for your support
     
  10. AngryAnt

    AngryAnt

    Keyboard Operator

    Joined:
    Oct 25, 2005
    Posts:
    3,045
    Placing a texture at /Assets/Gizmos/TypeName.png will make Unity use that texture as the icon of all instances of TypeName.
     
  11. AngryAnt

    AngryAnt

    Keyboard Operator

    Joined:
    Oct 25, 2005
    Posts:
    3,045
    Since the debugger in Behave 2 is now remote, you need to tell Behave when to update the debugger information - so as to not spam the network. If you see the end of the Flow chapter of the documentation, two options for updating the debugger is described there.

    If you are already doing this and still not seeing your runtime show up in the debugger overview, try hitting the refresh button for the view a few times.

    Let me know if this gets you up and running.

    While already placed decorators will still compile and run, I am indeed phasing them out. So you are not able to add new instances of the old decorators to your trees. The old decorators are replaced by a decorator control node type - the two instances of which are the repeater and the interrupter control nodes. See the documentation or in-editor node description for more details on how these work.

    Basically the new decorators spell the end of custom agent handlers for decorators and the beginning of much more flexible and re-usable control over decorator behaviour.
     
  12. Abl4ze

    Abl4ze

    Joined:
    Sep 6, 2013
    Posts:
    3
    Thank you for the help, i got around with the decorators now, the only thing i noticed is that the result from the interrupter is set to Failure if the check action returns Failure, where it first was Success with the Decorator.

    A new problem that occured to me is, that after i created a new Library (to leave everything working) and added all my changes, i now get a Compile Error: Object reference not set to an instance of an object.
    Any idea what could cause this?
    Because i have no other informations about what went wrong besides this message.

    P.S. Would there be the possibility that you add a email adress for support requests to the documentation, because I could find any contact possibility other than the forum and I would prefer the communication over email.
     
    Last edited: Sep 9, 2013
  13. AngryAnt

    AngryAnt

    Keyboard Operator

    Joined:
    Oct 25, 2005
    Posts:
    3,045
    Yea I would need a bit more information to guess at that nullref, but I did recently schedule a bugfix for a nullref being thrown if a library is built with one of its trees being completely empty. Could this perhaps be what you are seeing?

    I am working on the final details for getting the internal forum for the AngryAnt community up and running. I will definitely look into setting this up with direct email support as well.
     
  14. Abl4ze

    Abl4ze

    Joined:
    Sep 6, 2013
    Posts:
    3
    This was actually the case, but still after adding nodes to the tree I get the compile error. As the only hint I get, is the error message,I unfortunately can't provide more informations. If you can send me an email address and if it helps to solve the issue I could send you the library via email.

    That sounds good, because we need to finalize the library, as we need to continue programming on the AI asap.
    Thank you again for your continous support.
     
  15. BuildABurgerBurg

    BuildABurgerBurg

    Joined:
    Nov 5, 2012
    Posts:
    566
    Hello Ant, are you really working on a tutorial? if yes then when can we expect to see this tutorial?

    I'm not an expert programmer so I think this package is probably not for me.

    Is this package intended for experts?

    I understand that if this package is intended for expert market then the fault lies in me making a purchase so soon.
    I've used other BT's from the asset store and managed to get them working quick enough to be productive, maybe this has made it more difficult for me learning your system.

    Thanks Ant
     
  16. TimB

    TimB

    Joined:
    Jan 19, 2011
    Posts:
    65
    Am I missing some sort of documentation for this?

    Such as:
    Step 1: Under "Project" Create -> "Behave Library"
    That seems important and I don't see it documented anywhere...

    Also, if I create a library, add one action, then click "Apply Changes" which is what I am assuming builds the library, I instantly recieve:

    Reload Assembly called from managed code directly. This will cause a crash. You should never refresh assets in synchronous mode or enter playmode synchronously from script code.
    UnityEditor.EditorUtility:ClearProgressBar()
    Behave.Compilers.Compiler:Compile(IBehaveAsset, String, Boolean)
    Behave.Editor.MainWindow:Compile(IBehaveAsset)
    Behave.Editor.MainWindow:Compile()
    Behave.Editor.MainWindow:OnLibraryCanvasGUI()
    Behave.Editor.MainWindow:OnCanvasGUI()
    Behave.Editor.MainWindow:<OnGUI>m__C(Int32)
    UnityEditor.EditorWindow:BeginWindows()
    BehaveWindowProxy:BeginWindows()
    Behave.Editor.BehaveWindow:BeginWindows()
    Behave.Editor.MainWindow:OnGUI()
    BehaveWindowProxy:OnGUI()
    UnityEditor.DockArea:OnGUI()


    Does anyone else get that? Or is this expected since it is reloading an assembly from managed code?

    How relevant are the old Behave tutorials, can I follow them? Or is there at least a basic package that contains a demo scene set up? I think this is the first Asset Store item I have purchased that doesn't have a demo scene.

    Thanks
     
  17. AngryAnt

    AngryAnt

    Keyboard Operator

    Joined:
    Oct 25, 2005
    Posts:
    3,045
    I do indeed have a tutorial scheduled. However please understand that lots people are requesting things and I unfortunately do not have the luxury of being able to work on Behave full-time. Rest assured that it is high priority though.

    Meanwhile, did you check out the example project on the community site?
     
  18. AngryAnt

    AngryAnt

    Keyboard Operator

    Joined:
    Oct 25, 2005
    Posts:
    3,045
    Not just you Tim. That was a pretty embarrassing omission from the documentation. Fixed for later release though.

    The error message is a known issue on Windows. It does not have any side effects and started spewing out of the blue in Unity 4.2. I have a case open with Unity to kill it.

    On the community site, available from the Help menu, you find the example project. I am however planning to move this to an asset store package in a bid to increase visibility.
     
  19. AngryAnt

    AngryAnt

    Keyboard Operator

    Joined:
    Oct 25, 2005
    Posts:
    3,045
    Please use the support link on the asset store to get the ball rolling on debugging this library.
     
  20. pneill

    pneill

    Joined:
    Jan 21, 2007
    Posts:
    207
    +1 for that tutorial. Can't wait to see it.
     
  21. pneill

    pneill

    Joined:
    Jan 21, 2007
    Posts:
    207
    Why does the interrupt node have three connections? Shouldn't it just have two (one for input and the other for success?)
     
  22. pneill

    pneill

    Joined:
    Jan 21, 2007
    Posts:
    207
    Also, one last issue. When I just create a library, toss in an action and compile, I get the following error. I'm using Unity 4.2 on the Mac with my player build settings set to iOS.

    Code (csharp):
    1. System.SystemException: Error running gmcs: Cannot find the specified file
    2.   at Mono.CSharp.CSharpCodeCompiler.CompileFromFileBatch (System.CodeDom.Compiler.CompilerParameters options, System.String[] fileNames) [0x00000] in <filename unknown>:0
    3.   at Mono.CSharp.CSharpCodeCompiler.CompileFromSourceBatch (System.CodeDom.Compiler.CompilerParameters options, System.String[] sources) [0x00000] in <filename unknown>:0
    4.   at Mono.CSharp.CSharpCodeCompiler.CompileAssemblyFromSourceBatch (System.CodeDom.Compiler.CompilerParameters options, System.String[] sources) [0x00000] in <filename unknown>:0
    5.   at System.CodeDom.Compiler.CodeDomProvider.CompileAssemblyFromSource (System.CodeDom.Compiler.CompilerParameters options, System.String[] fileNames) [0x00000] in <filename unknown>:0
    6.   at Behave.Compilers.Unity.Compile () [0x00000] in <filename unknown>:0
    7. UnityEngine.Debug:LogError(Object)
    8. Behave.Runtime.Resources:LogError(String, Object[])
    9. Behave.Compilers.Unity:Compile()
    10. Behave.Compilers.Compiler:Run()
    11. Behave.Compilers.Compiler:DoCompile(IBehaveAsset, String, String, Boolean)
    12. Behave.Compilers.Compiler:Compile(IBehaveAsset, String, Boolean)
    13. Behave.Editor.MainWindow:Compile(IBehaveAsset)
    14. Behave.Editor.MainWindow:Compile()
    15. Behave.Editor.MainWindow:OnLibraryCanvasGUI()
    16. Behave.Editor.MainWindow:OnCanvasGUI()
    17. Behave.Editor.MainWindow:<OnGUI>m__C(Int32)
    18. UnityEditor.EditorWindow:BeginWindows()
    19. BehaveWindowProxy:BeginWindows()
    20. Behave.Editor.BehaveWindow:BeginWindows()
    21. Behave.Editor.MainWindow:OnGUI()
    22. BehaveWindowProxy:OnGUI()
    23. UnityEditor.DockArea:OnGUI()
     
  23. pneill

    pneill

    Joined:
    Jan 21, 2007
    Posts:
    207
    To answer my own question for the benefit of others. Looks like this is a known unity issue on the Mac. Solution is to create a link

    Code (csharp):
    1. sudo ln -s /Applications/Unity/MonoDevelop.app/Contents/Frameworks/Mono.framework/Versions/2.10.2/bin/gmcs /usr/bin
     
  24. AngryAnt

    AngryAnt

    Keyboard Operator

    Joined:
    Oct 25, 2005
    Posts:
    3,045
    Hey pneill

    Yea that Unity issue is becoming a joke. I have it on my TODO to abandon the public compiler APIs and do the pathing myself, since Unity clearly has no interest in fixing it.

    Regarding the interrupt behaviour, please see the documentation for an in-depth description of how each component works.
     
  25. AngryAnt

    AngryAnt

    Keyboard Operator

    Joined:
    Oct 25, 2005
    Posts:
    3,045
    The Behave 2 forums are now live!

    I finally overcame some really annoying unexpected obstacles and the AngryAnt community forums are now live. Please move all Behave 2 discussion there, leaving this thread dedicated to Behave 1 support.
     
  26. AngryAnt

    AngryAnt

    Keyboard Operator

    Joined:
    Oct 25, 2005
    Posts:
    3,045
  27. Greggeli

    Greggeli

    Joined:
    May 10, 2013
    Posts:
    1
    Hi,

    I have a GO with 3 scripts, one of them is an implementation of a tree. I don't know if it is the correct way to do it but I'd like to set public variables of the tree script from another script.
    So in the other script I call GetComponent to get the instance of the tree script and I set the variable through a public setter method.
    The problem is that the variable I set are not updated correctly inside the tree script. In the setter method when I log the state, they are updated correctly, but when I read the private variable in the tick method for example, I can only read some old value.

    I am doing something wrong there?

    Thanks

    Edit: I run 1.4
    Edit2: disregard this post, since I didn't realise something is setting my value back to 0..... I will investigate.
     
    Last edited: Oct 11, 2013
  28. vidrohi

    vidrohi

    Joined:
    Dec 3, 2012
    Posts:
    14
    So this is a query I have plastered literally everywhere I can on the internet, I even bugged Emil about it on his twitter (Sorry Emil, didnt mean to hijack your twitter into a tech support page, but I was making no headway anywhere), anyway, here is my issue.

    I am using the Behave Plugin to make behavior trees for my game

    So, I have a behavior tree that looks like this : http://imagebin.org/278510

    The Actions marked in Red are basically Perpetually Running actions once reached, they make my guard perpetually rotate in 360 degree circles or 180 degree scans.

    This works as expected and everything is fine, however, when a higher priority subtree is introduced things get hairy, So, suppose my higher priority subtree chases the player when he is seen, the guard chases the player eventually loses him, now, I want the patrolSubtree to be completely Re-evaluated (i.e. starting from goToWayPoint) , it will however , come to the patrolSubtree sequence and see that a chain leading to doScanFull is "Running" and will start to rotate the guard "in place" wherever it was when it lost the player.

    I believe there should be some way to resolve this, as even in the case of non "Perpetually" running actions, this may cause unexpected behavior when a "Running" action is interrupted by a higher part of the tree.

    Can anyone suggest a way to do this ?

    I think there should be a way to reset the entire subtree at whim, so that all "Running" actions are cleared, or is there some better way ?

    Furthermore, What if I dont want my Top level Selector to be affected by the "Running" state on any Action ? i.e. I want that selector to check every possibility underneath it to see which one to run , that way , if the guard is doing a HalfScan and he sees the player , the "Chase Subtree" will actually evaluate. If the Top level Selector was affected by the Running state of stuff under it though, then the higher priority actions may never evaluate because some stuff was in the "Running" state.

    Thanks a lot, Nik
     
  29. vidrohi

    vidrohi

    Joined:
    Dec 3, 2012
    Posts:
    14
    Really ? No one knows ? :(
     
  30. AngryAnt

    AngryAnt

    Keyboard Operator

    Joined:
    Oct 25, 2005
    Posts:
    3,045
    Hey vidrohi

    I'm sorry I didn't spot your post earlier. Unfortunately at this point your image is offline. Is your situation still unresolved?
     
  31. AngryAnt

    AngryAnt

    Keyboard Operator

    Joined:
    Oct 25, 2005
    Posts:
    3,045
  32. vidrohi

    vidrohi

    Joined:
    Dec 3, 2012
    Posts:
    14
    Hello All,
    So I have been struggling with this problem for a while now, I need to program interrupts into my behavior tree that are executed every time an action happens and allow for bailing out when higher priority actions need to be taken.

    I thought that I could just put a decorator in the way and then return a Failure on the decorator to achieve the desired result, this however seems to not work because apparently when a decorator tick returns Failure, the Decorator itself returns Success.

    I am extremely confused as to how to program interrupts in my code without having to write the relevant code in each and every one of the actions being taken.
     
    Last edited: Jan 5, 2014
  33. vidrohi

    vidrohi

    Joined:
    Dec 3, 2012
    Posts:
    14
    Hello Emil, I thought I had resolved it , but unfortunately it seems my solution was not correct.

    Here is the image again (http://imagebin.org/285226) , I am basically trying to find out a way to program interrupts, without having to put interrupting code in literally every action that I take.
     
  34. AngryAnt

    AngryAnt

    Keyboard Operator

    Joined:
    Oct 25, 2005
    Posts:
    3,045
    Yea 1.x decorators were extremely silly. I ripped them out and replaced them with a control type node in 2.0.

    Your options for interrupting are decorators and parallels. Unfortunately, as you discovered, 1.x decorators have no way of returning failure.
     
  35. vidrohi

    vidrohi

    Joined:
    Dec 3, 2012
    Posts:
    14
    Ah, Ok, that's unfortunate! So assuming that I cannot , at this point migrate to 2.0 , is there any real technique that I can use to properly implement a parallel interrupt which does not devolve into me setting some bool in the left most parallel node and checking for it in all the actions that happen subsequently on the right side so as to skip over all (or whichever one I am at) of them by either returning failure or succeeding ?
     
  36. AngryAnt

    AngryAnt

    Keyboard Operator

    Joined:
    Oct 25, 2005
    Posts:
    3,045
    Interrupt via parallel would be set up by configuring the parallel to complete whenever one of the child nodes complete. With that set up, in order to interrupt you just need a leftmost action return Running by default and non-Running when you want to interrupt.
     
  37. vidrohi

    vidrohi

    Joined:
    Dec 3, 2012
    Posts:
    14
    Ah, ok so I should set the Parallel "Component Completion" to One and Child Completion to "Success of Failure" to achieve what you are suggesting.

    There is one last unknown with this, at what level would I need to implement the parallel, would it be at the lowest level of granularity ? Or can I do something like this http://imagebin.org/285278 wherein "Wait for Align" is something that will run over multiple frames does a Parallel work like Decorators wherein it gets ticks all its children on the way if something under it has returned "Running" or will I have to implement it much more granularly wherein there is a parallel interrupt that is paired with every task that may run over multiple frames ?

    Finally, have you or someone else written a tutorial elucidating these techniques ?

    Really Appreciate the help btw.
     
  38. AngryAnt

    AngryAnt

    Keyboard Operator

    Joined:
    Oct 25, 2005
    Posts:
    3,045
    The Parallel will tick all child connections in order each tick - even if one or more returns running for several ticks. So you can really put it wherever it makes sense to you.

    IIRC http://arges-systems.com/ had some Behave 1 tutorials at one point. Not sure about the coverage.
     
  39. vidrohi

    vidrohi

    Joined:
    Dec 3, 2012
    Posts:
    14
    Heh, yeah, The Arges systems tuts were the ones I looked at before. At one point the person who wrote them suggested that you had said Decorators could be used for interrupts, barring any word from you , that was the premise I was working under, unfortunately that was not entirely correct :(

    This is the article that I was looking at (obviously a very old one) http://arges-systems.com/blog/2009/04/13/behavior-trees-on-actual-use/ , the last few lines are where he says that , unfortunately the follow up tutorial never came, I assume because it is not possible.

    Ok, so just as a test, I made the necessary changes in my code and the solution seems promising aside from one detail, if I want to bail out I dont want the action that is paired as a parallel to even execute, however, it seems that parallel nodes execute all children regardless of execution rules , so even if the first child (our interrupter) returns a non running state , the second one in line gets ticked atleast once.
    Is there any way to tell the parallel to stop at first failure ? (the behavior sounds like a sequence but is not) The only other way I can think of doing this would be setting a bool or something in the leftmost action and checking it in the actions on the right to ensure that they are never executed.
     
  40. AngryAnt

    AngryAnt

    Keyboard Operator

    Joined:
    Oct 25, 2005
    Posts:
    3,045
    Only the decorator can prevent at least one tick like you describe. The only drawback it has is its inability to return failure.
     
  41. vidrohi

    vidrohi

    Joined:
    Dec 3, 2012
    Posts:
    14
    So , in essence an interrupt which just stops everything in place, bails out and forces tree re-evaluation is not really possible with 1.x ?
     
  42. AngryAnt

    AngryAnt

    Keyboard Operator

    Joined:
    Oct 25, 2005
    Posts:
    3,045
    No what you quoted says the exact opposite. For an immediate interrupt, you should use the decorator.

    However the whole "forces tree re-evaluation" bit is new in this conversation. That suggests you're after something different from what you have been describing.
     
  43. vidrohi

    vidrohi

    Joined:
    Dec 3, 2012
    Posts:
    14
    Ah, so we are talking two different types of interrupts then ? One parallel and one Decorator based , both of which may be needed in the same project ?

    By tree re-evaluation (maybe I am using the term incorrectly) I was just referring back to what I had asked about in my original question , as to when some (new) conditions arise and I am in an action that Keeps returning "Running", I need to be able to bail out and have the tree evaluate again to check if based on the current state of the world, is there a higher priority action that I need to take (otherwise it will just keep on Running the low priority action that it is in right now)
    That perpetually running action is what I want to bail out of and then force the tree to find a better fit for the current situation.
     
  44. AngryAnt

    AngryAnt

    Keyboard Operator

    Joined:
    Oct 25, 2005
    Posts:
    3,045
    If you just need to reset absolutely everything and start over, you can just call myTreeReference.Reset ();
     
  45. vidrohi

    vidrohi

    Joined:
    Dec 3, 2012
    Posts:
    14
    Ah, using that inside a decorator should give me some of what I need. Although if I wanted to have something that did not reset the entire subtree and just bailed out of those specific actions looking for an alternative just one level up the chain I will probably require some more trickery.

    Ok, armed with all this info, I will try and go do some more work :)
    Once again, I really appreciate all your help, hopefully my next post will be about how I got everything working.


    On a side note, I love your title of "Keyboard Operator" on the website!
     
  46. oOoANDOSoOo

    oOoANDOSoOo

    Joined:
    Jun 17, 2013
    Posts:
    28
    Hi there,
    So, after reading up on game AI and path-finding and such I have been looking for an asset that would possibly aid me in my games development. After coming across 'Behave' I was anxious to try it out... but I can not find any trial/evaluation version of Behave 2.

    I am sure that Behave is a fantastic asset but $200 is rather steep and there is no evaluation version to even have a go and see if it is right for people. Even the Behave website community forums and documentation are all locked unless you purchase Behave first and supply the serial code to register on the website.

    It is a shame that those of use who do not have this can not get to try it out before committing to a purchase.

    :)

    Cheers,
    -Andy
     
    Last edited: Jan 22, 2014
  47. goldbug

    goldbug

    Joined:
    Oct 12, 2011
    Posts:
    767
    We bought behave 2.3.2 and we are getting this error when trying to run in ios:

    Failed to load AOT module '/var/mobile/Applications/35154031-6800-45A9-A680-7E48F0C757AE/blockslight.app/Data/Managed/Behave.Unity.Assets.dll.dylib' in aot-only mode.
     
  48. AngryAnt

    AngryAnt

    Keyboard Operator

    Joined:
    Oct 25, 2005
    Posts:
    3,045
    @oOoANDOSoOo:
    I unfortunately do not currently have the bandwidth to build an evaluation version of Behave. Though all online resources, except for the internal forum, are now available pre-purchase.

    @goldbug:
    I replied to your PM :)
     
  49. CodeMonke234

    CodeMonke234

    Joined:
    Oct 13, 2010
    Posts:
    181
    Andy -
    I am also thinking about buying Behave - I did find the public documentation - it was a little hard to find....not sure if you found it...

    Here is the link:
    http://eej.dk/community/documentation/behave/0-Introduction.html
     
  50. AngryAnt

    AngryAnt

    Keyboard Operator

    Joined:
    Oct 25, 2005
    Posts:
    3,045
    Thank you for bringing it up. I have ensured that the documentation is now directly linked from the asset store page as well :)