Announcement

Collapse
No announcement yet.

Behavior Tree Extension - Select behaviors based on dynamic priority weighting.

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

    [PLUGIN] Behavior Tree Extension - Select behaviors based on dynamic priority weighting.

    **Updated to 4.12+**

    Hey guys.

    BTUtility is a simple plugin that adds a new node type to the UE4 behavior tree. It doesn't require C++ or any special integration steps.

    The Utility selector is similar to the built in Selector node, but prioritizes children based on a utility value attached to each child via a special decorator node.

    Click image for larger version

Name:	BTUtilityExampleImage2.png
Views:	1
Size:	167.0 KB
ID:	1166757

    There are three basic types of utility decorator: constant, blackboard, or using a custom blueprint that will evaluate each time the Utility node starts.

    Example uses are to add some random variation to AI behaviors, or to select a behavior by weighting various criteria to determine what is most important to the AI at the time.


    It's available in binary form (just unzip into .../YourProject/Plugins or Engine/Plugins) and the source code is also on Github (MIT license).
    Links and more info here.

    This was originally an engine mod and there's still a chance it might make it in as a PR at some point. It's been sitting around for a while though, so when I realized most of it could be done in plugin form I figured I might as well release it to the community now.

    Enjoy, and if you have any questions or problems with it, just post here. Cheers.
    Last edited by kamrann; 08-31-2016, 12:51 PM.

    #2
    I like this

    Comment


      #3
      Excellent stuff
      Thanks

      Comment


        #4
        No worries, happy if somebody can make some use of it.

        Comment


          #5
          I was about to figure out a weighing system for my AI. Seems like this exactly what I'm looking for

          Comment


            #6
            Thanks for making this... Looks really neat. Are you updating when newer versions of UE4 come out? Thanks again!

            teak
            "A little bit of nonsense now and then is cherished by the wisest men..."
            -- Willy Wonka

            twitter: @teak421 -- Smooth Zoom Camera Plugin for 4.14+: here.

            Comment


              #7
              Yeah I'll do my best. Won't always be immediate but if anyone upgrades and has an issue with it, just let me know here.

              To be honest I'd expect it to require close to zero maintenance in this respect anyway. The core behavior tree API won't change much from here on I wouldn't think.

              Edit: Just built for 4.11 P4, no problems. I'll push up a binary build when 4.11 gets released.
              Last edited by kamrann; 01-29-2016, 08:38 AM.

              Comment


                #8
                Interesting implementation. Have you experimented with modifying the base BT nodes so you can use all existing BT nodes? I added a utility goal based virtual that is overridden on a sequence and selector and evaluated in custom decorators and tasks and found it to be more flexible.

                Comment


                  #9
                  @dzeligman: I'm not quite sure what you mean by 'so you can use all existing BT nodes', or what the meaning of utility would be in the case of a sequence node? If you can explain or give an example of what result can't be achieved with my setup, I'd be happy to look into it.

                  I can say though that this was developed with input from Epic's Lukasz Furman, since it was initially written with a possible PR in mind. As such, it was done in a way so as to:
                  1. Minimize changes to existing engine code (obviously since it was converted to a plugin, there are now none).
                  2. Add as little as possible in terms of new nodes/new UI, to avoid adding complexity to the BT editor.
                  3. Respect some fairly strict rules defining how decorators should behave, and in particular how a composite is allowed to choose child execution based on decorators.

                  Outside of these restrictions, then of course there is a whole lot more functionality and flexibility that could potentially be added.
                  One thing I did consider was having a kind of two-tier utility, with utility functions returning an integer priority class along with the float utility value. That would I think allow more easy control over which child was executed, by first filtering children to the highest priority class available, before selecting based on utility value.

                  Comment


                    #10
                    When shooting for those goals it makes sense. It def appears pretty simple and easy to extend. What I meant when saying use all existing nodes is being able to do more DFS/recursive based lookup of utility. Independent utility for selectors and sequences. Its possible my current implementation does not obey all decorator execution rules such as latent abort/event based execution as a result.

                    Comment


                      #11
                      Originally posted by dzeligman View Post
                      What I meant when saying use all existing nodes is being able to do more DFS/recursive based lookup of utility.
                      Right yeah I think I see what you're getting at. Yep, it's certainly a pretty simple implementation, though makes it easy to do a lot of things that were hassle or borderline impossible with the default nodes alone. Truth is though I did this as an engine learning exercise, it wasn't driven by any particular project needs. So as yet I haven't really made much use of it or tested the limitations.

                      Appreciate the feedback.

                      Comment


                        #12
                        I'm getting a build error when trying to compile anything with this plugin enabled:
                        Code:
                        MainFrameActions: Packaging (Windows (32-bit)): CommandUtils.Run: Run: F:\Games\Unreal Engine 4\Epic Games\4.10\Engine\Binaries\DotNET\UnrealBuildTool.exe SpaceBossesCPP Win32 Development -clean F:\Projects\UE4\SpaceBossesTD_Fork\SpaceBossesCPP.uproject  -remoteini="F:\Projects\UE4\SpaceBossesTD_Fork" -nobuilduht -rocket -NoHotReloadFromIDE
                        MainFrameActions: Packaging (Windows (32-bit)): UnrealBuildTool: ERROR: Couldn't find module rules file for module 'BTUtilityPlugin'.
                        MainFrameActions: Packaging (Windows (32-bit)): CommandUtils.Run: Run: Took 1,237922s to run UnrealBuildTool.exe, ExitCode=5
                        complete log: http://pastebin.com/TJh9vctJ

                        Comment


                          #13
                          Hi aureon.

                          Am I right in assuming you added the binary form of the plugin into the Plugins directory within your project, and also that your project contains C++ code?

                          I am having this same issue with another plugin I'm currently developing for the marketplace. As far as I can tell, for projects with C++, UBT assumes plugins should have source code too and generates this error if only the binaries and content exist. Blueprint-only projects with binary plugins work fine, as do C++ projects with plugins with source code. I'm currently awaiting a response from marketplace staff regarding this.

                          In the meantime, if you clone or download the Github repo linked in the original post, and put the whole thing into your project's Plugins directory, I think you may find that fixes the problem.

                          Comment


                            #14
                            I've already done so, but this results in:
                            Code:
                            MainFrameActions: Packaging (Windows (64-bit)): UnrealBuildTool: ERROR: UBT ERROR: Failed to produce item: F:\Projects\UE4\SpaceBossesTD_Fork\Plugins\BTUtilityPlugin\Binaries\Win64\UE4-BTUtilityPlugin.lib
                            MainFrameActions: Packaging (Windows (64-bit)): UnrealBuildTool: Total build time: 99,49 seconds

                            Comment


                              #15
                              Hmm, is there no output prior to that, detailing the error?

                              Can you let me know a bit more about your setup - engine version (I assume 4.10), build config (Development/Shipping and Editor/Game), and how you're building (it looks like you're packaging? Do you get this error if you just do a straight build, either UBT command line or within Visual Studio?).

                              Sorry you're having problems. If you can give me more info I'll look into it right away.

                              Comment

                              Working...
                              X