Behavior tree AI in under 10 minutes! Godot 3.5 Tutorial

แชร์
ฝัง
  • เผยแพร่เมื่อ 20 ต.ค. 2024

ความคิดเห็น • 126

  • @killax1000
    @killax1000 2 ปีที่แล้ว +22

    I'm making a game where you employ NPCs to do things like chop trees, mine, craft, whatever. This couldn't be more perfect.

  • @bitbraindev
    @bitbraindev  2 ปีที่แล้ว +21

    Thank you a lot for watching! Subscribe to my channel for more gamedev stuff and let me know in the comments what you want me to do next!
    ⚠ EDIT: as raised by Gareth Somers, at 5:45 we also have to wrap the condition inside a SelectorComposite as shown in the video (I forgot to mention it)

  • @Luisa-mu9yw
    @Luisa-mu9yw 2 ปีที่แล้ว +7

    This is literally what I've been struggling with today!! Really cool, thank you! :)

  • @ThunderThoster
    @ThunderThoster 2 ปีที่แล้ว +8

    I love it! Considering I started learning Godot one month ago and game development in general, I believe it will take me some time to completely understand how the code works, although I checked the code and have an inkling of an idea. But before that even happens, gotta practice a lot of mechanics. Either way, thank you for the video; I will come back to it when the time comes :D

  • @KyleLuce
    @KyleLuce 2 ปีที่แล้ว +3

    Oh nice you wrote a behavior tree plugin! I was thinking of doing this eventually, so you probably saved me a bunch of time :)

  • @PMX
    @PMX 2 ปีที่แล้ว +6

    3:14 WlakToClosestTree seems to be "closest in a straight line", but "closest by walking distance" (ie taking into account the path it can actually use) would probably be what the user expects. Of course, that's more expensive to calculate, but you can limit the calculation to the closest (in straight line) 10-20 trees for a good enough heuristic.

  • @mirage3dee
    @mirage3dee 2 ปีที่แล้ว +4

    Well done. Beautifully simple implementation.

  • @slothinahat
    @slothinahat 2 ปีที่แล้ว +4

    This is so cool I was just trying to do this in my own game!

  • @teo2805
    @teo2805 2 ปีที่แล้ว +31

    Can we get a part two/followup? I'm a bit confused on a few things that were explained too fast. Like, why do I need an inverter "HasNoTreeAvailable" with a "HasTreeAvailable" check after?
    Could you make some enemy AI examples using your addon too? Or could i look at more examples from your game

    • @bitbraindev
      @bitbraindev  8 หลายเดือนก่อน +6

      Working on a much more basic and thorough tutorial for Godot 4 that will explain everything in detail 🙌

    • @PaperMouseGames
      @PaperMouseGames 7 หลายเดือนก่อน

      @@bitbraindev Are you still working on this? I would love an updated more in depth version of this video!

    • @bitbraindev
      @bitbraindev  7 หลายเดือนก่อน +3

      Yeah. Good things take time.

    • @PaperMouseGames
      @PaperMouseGames 7 หลายเดือนก่อน

      @@bitbraindev glad to hear it! Looking forward to it ☺

  • @MegaZumo
    @MegaZumo 2 ปีที่แล้ว +8

    This is the best behavior tree Godot tutorial, the other ones are really simple. Great job! =) Btw I've seen on the assetlib two BehaviorTree plugins, is there a reason why you decided to create your own?

    • @bitbraindev
      @bitbraindev  2 ปีที่แล้ว +6

      Great question! I actually tried all available addons in the asset store and none of them were simple enough for me. Either, they were lacking the "selector star" functionality and important decorator nodes or they were visual only. Also, the documentation for them was rather lacking.
      My addon is directly based on the demo project from th-cam.com/video/YHUQY2Kea9U/w-d-xo.html - however, I have plans to introduce also a visual debugger for my addon and actively develop it for better debugability.

    • @MegaZumo
      @MegaZumo 2 ปีที่แล้ว +2

      @@bitbraindev I see, I will use your addon then. I have been studying the code and it was very easy to understand. Do you have any plans to upload it to the assetlib?

    • @bitbraindev
      @bitbraindev  2 ปีที่แล้ว +7

      @@MegaZumo ​ it is there already! Just type 'bee' and it should show up.

    • @MegaZumo
      @MegaZumo 2 ปีที่แล้ว +2

      @@bitbraindev nice!

  • @API-Beast
    @API-Beast ปีที่แล้ว

    Oh, wow, this is really good! Good job dude.

    • @bitbraindev
      @bitbraindev  ปีที่แล้ว +1

      Thank you! I am working on an updated video for Godot 4 that dives a bit more into the mechanics of behaviour trees.

  • @ezrawallet
    @ezrawallet 2 ปีที่แล้ว +4

    I’d love to see complex enemy pathfinding in another video - my top down game often has enemies get stuck on corners when they chase the player and it can be kind of easy to cheese them.

    • @bitbraindev
      @bitbraindev  2 ปีที่แล้ว +7

      I am actually planning to build exactly that as a separate tutorial soon! The pathfinding in this demo is rather poor because the NavigationAgent2D in the Godot 3.5 RC while recording the tutorial was incomplete. Now, they fully cherry-picked also the navigation mesh and collision stuff from Godot 4 which definitely makes things easier.

    • @_gamma.
      @_gamma. 2 ปีที่แล้ว +3

      @@bitbraindev will that also show creating the various nodes for use in the tree? Love the addon but I’m having some trouble wrapping my head around it

  • @AdemOmerovicBA
    @AdemOmerovicBA ปีที่แล้ว

    My man, you made an add-on for a thing that I needed ❤

    • @bitbraindev
      @bitbraindev  ปีที่แล้ว

      Glad beehave is useful to you!

  • @vojtastruhar8950
    @vojtastruhar8950 ปีที่แล้ว

    This is mind blowing. Great job!!! Can't wait to try this out

    • @bitbraindev
      @bitbraindev  ปีที่แล้ว

      Thank you! New tutorial hopefully dropping next week.

  • @_gamma.
    @_gamma. 2 ปีที่แล้ว

    Will have to check out this addon, love the name!

  • @mythology100
    @mythology100 ปีที่แล้ว

    @bitbraindev been studying and practicing your addon for developing enemy AI for a top-down shooter game. Has been boggling me why Godot 4 does not have such a system backed into it, but this has been a welcoming lesson. Still need to understand a few more things to make a better enemy AI behavior.
    Wishing you the best in the future!

    • @bitbraindev
      @bitbraindev  ปีที่แล้ว +1

      Thanks a lot! If you have any ideas or feedback on the addon feel free to create a discussion or issue on Github: github.com/bitbrain/beehave/discussions/new?category=ideas

  • @olmrgreen1904
    @olmrgreen1904 2 ปีที่แล้ว +1

    Awesome video! Thanks!

  • @CirculensProductions
    @CirculensProductions 7 หลายเดือนก่อน

    Beautiful tutorial, it helped me so much to understand the chapter 6 of game ai pro book

  • @beidero
    @beidero 2 ปีที่แล้ว +12

    This is a very intersting video, I always like AI stuff. In a past tutorial I made on my youtube I did something similar but in pure C#, and it was quite efficient. I am a programmer so I think I prefer having it in my text editor over being a node, but I guess for most people it would be the other way around. Either way a great tutorial

    • @kevinhougesen1473
      @kevinhougesen1473 ปีที่แล้ว

      I also prefer it in text editor since I'm also not a standard game dev, but I think this way is preferred because Godot itself updates the changes if you move the files in the 'res://' folder. That way you don't have to update a lot of scripts if changing the organizing structure of the game.

  • @yayvey
    @yayvey 10 หลายเดือนก่อน

    This is still very valuable information. Thank you!

  • @FlorianHanke
    @FlorianHanke 2 ปีที่แล้ว +5

    This is a very well done tutorial, thank you!
    One small improvement I'd make is to have nodes initialize themselves with relevant values (e.g. the stash_area), so the root does not need to know about what subnodes need. The way I'd do this in the _ready function of the root, it'd visit all subnodes and if they have for example an "initialize" method, it would call that with itself as param. Then, when a subnode's initialize is called, it could pick whatever relevant value (e.g. stash_area) and set it on itself.

    • @bitbraindev
      @bitbraindev  2 ปีที่แล้ว +2

      Great thinking! Another idea I had was to follow the "signal up, call down" methodology more. And then using an event bus to communicate information from within the behaviour tree outwards.

  • @Noobrzor
    @Noobrzor 2 ปีที่แล้ว +2

    bitbrain? More like petabytebrain! Thanks for the tutorial!

    • @bitbraindev
      @bitbraindev  2 ปีที่แล้ว +1

      01010100 01101000 01100001 01101110 01101011 01110011 00100001

  • @megalukes
    @megalukes 10 หลายเดือนก่อน

    Hey there, bitbrain. Is there a tutorial about behaviour trees you would recommend for an absolute beginner? I've considering using behave for managing NPC conversations in my project, but I still feel I lack a good foundation about all of these nodes like selectors and decorators. Thank you so much!

  • @TheSlimHim
    @TheSlimHim 2 ปีที่แล้ว +4

    Can you explain why you made your own behavior tree instead of using one already in the plugins? I haven't explored behavior trees in Godot yet so I was wondering if what else is available is lacking.

    • @bitbraindev
      @bitbraindev  2 ปีที่แล้ว +2

      Great question! I added an explanation here: github.com/bitbrain/beehave/blob/godot-3.x/README.md#-yet-another-behavior-tree-addon

    • @TheSlimHim
      @TheSlimHim 2 ปีที่แล้ว

      @@bitbraindev Thank you! That's was super helpful!

  • @nobodyinparticular80
    @nobodyinparticular80 ปีที่แล้ว

    Woah, this went over my head @_@

  • @clecioespindolagamedev
    @clecioespindolagamedev ปีที่แล้ว

    Hj, can I use your tutorial as a base to create a portuguese version of this content? I won't do the same, but use it as a reference, adding my concernes and tips. And of course crediting your channel.

  • @BeThoR94
    @BeThoR94 3 หลายเดือนก่อน

    First of all, I want to thank you for this great tutorial. I have a question though, I think I might be misunderstanding how each node works, but the documentation explains that when a child of a sequence node returns "running" both sequencecomposite and sequencestarcomposite Tick Again. Looking at the code in the demo project I can see that the behavior is as explained in the video, but I think that is not reflected in the documentation. Can you clarify this point? Please.

    • @bitbraindev
      @bitbraindev  3 หลายเดือนก่อน +1

      The logic is wrong in the demo. The documentation is correct.

  • @AFE-GmdG
    @AFE-GmdG ปีที่แล้ว

    This is a really cool and helpful addon! Thank you for your hard work.
    How does this work in Godot 4? Do you already upgrade the addon to it or do you have a time planned?

    • @bitbraindev
      @bitbraindev  ปีที่แล้ว +1

      The addon supports Godot 4, yes! However, the tutorial codebase is not upgraded (yet)

  • @languagelearningexperience6814
    @languagelearningexperience6814 2 ปีที่แล้ว

    Awesome explanation

  • @matt1871
    @matt1871 2 ปีที่แล้ว +4

    I'd love to see an in-depth travelling NPC merchant/trader video. It's really something I'm struggling to find a good video on!
    I loved this one, thanks so much 😄

  • @alextkd2003
    @alextkd2003 ปีที่แล้ว

    Please more tutorials about this plugin 🙏🙏

  • @DocMinemomo
    @DocMinemomo ปีที่แล้ว +1

    Nice Tutorial~ It helps me alot! But I still have a problem in Beehave Version 1.2.0 , When I added a ConditionLeaf node or ActionLeaf node , There is a "Condition.gd" Script attached on them, I already know that I can add my own script by click "Extend script", but Is there any way to generate a script contains tick function and classname automatically?

  • @andrewallbright
    @andrewallbright 2 ปีที่แล้ว +1

    (1) event driven behavior trees... How do they work?
    (2) backchaining... Is it just a way of building a behavior tree or is it a way of simulating a GOAP?
    (3) when is it appropriate to represent my behavior tree as a tree graph in code?
    (4) why do some behavior tree implementations combine actions and conditions (sometimes called an action's precondition)?

    • @bitbraindev
      @bitbraindev  2 ปีที่แล้ว +1

      Wonderful questions!

    • @andrewallbright
      @andrewallbright 2 ปีที่แล้ว +1

      @@bitbraindev I have so many questions. I've spent time thinking and researching on behavior trees. They're magical things really.

  • @Rioni
    @Rioni ปีที่แล้ว

    Is there some way to always run a node at the end of the sequence? I was using a always succeed decorator, but that doesn't work when the node is running. I'm not sure if what I want is even possible or if I should check other approach

    • @bitbraindev
      @bitbraindev  ปีที่แล้ว

      This will work by using a parallel node: github.com/bitbrain/beehave/issues/58

    • @Rioni
      @Rioni ปีที่แล้ว

      @@bitbraindev Oh cool! This feature highly interests me, once I finish the current PR I'll slowly look into that one, I think I can add some help there

  • @ThunderPlayStudios
    @ThunderPlayStudios 2 ปีที่แล้ว

    this video is gold

  • @zephy6446
    @zephy6446 2 ปีที่แล้ว +1

    Hey loved the video! What godot theme is that?

    • @bitbraindev
      @bitbraindev  2 ปีที่แล้ว +1

      Here you go! github.com/bitbrain/godot-dash

    • @zephy6446
      @zephy6446 2 ปีที่แล้ว

      @@bitbraindev Its so freakin nice thank you bro!

  • @KaletheQuick
    @KaletheQuick 2 ปีที่แล้ว

    Ok, but lets not just gloss over how cute thes goblins are :3

    • @bitbraindev
      @bitbraindev  2 ปีที่แล้ว

      These are created by Daniel Diggle! danieldiggle.itch.io/sunnyside

  • @sirnad7813
    @sirnad7813 2 ปีที่แล้ว

    We need more about AI movement ❤✊

  • @ВикторТаланцев-д8ж
    @ВикторТаланцев-д8ж 2 ปีที่แล้ว +1

    Вы забыли добавить логику, что если мишень уже занята другим рабочим, то он не имеет права его трогать, иначе 10 лесорубов режет коноплю, это не хорошо, как и другое поведение, если лесоруб знает, что ящик полон, то не уничтожайте его, а сбрасывайте на пол и отправляйтесь отдыхать.

    • @bitbraindev
      @bitbraindev  2 ปีที่แล้ว

      That makes sense! For anybody unaware: I haven't considered that certain trees might be "busy" already by other workers. Additionally, boxes should be dropped on the ground rather than being destroyed, when there is no more space available.

  • @longuemire748
    @longuemire748 3 หลายเดือนก่อน

    Thank you for this tutorial.
    Excuse me, but it's easy to transpose to another tree behaviour? I'd like to do it with limbo on Godot?

    • @bitbraindev
      @bitbraindev  3 หลายเดือนก่อน +1

      That should be doable, yes.

    • @longuemire748
      @longuemire748 3 หลายเดือนก่อน

      @@bitbraindev thank you, i bought the sunnyside world pack but i can't find the png: "sunnyside_world_chatacter_anim_GOBLIN.png". Did you make it?

  • @adibrahman9297
    @adibrahman9297 2 ปีที่แล้ว

    Awesome 👍🏾

  • @KlausWulfenbach
    @KlausWulfenbach 2 ปีที่แล้ว +2

    Do you really need to make the inverter a node, or could you add an exported boolean to condition nodes that inverts the logic?

    • @bitbraindev
      @bitbraindev  2 ปีที่แล้ว +3

      Of course you could but it would make things less obvious. During debugging, to fully understand what is happening you'd need to check every node and see if it had the flag activated or not. The goal here is to make things explicit within the node tree view itself.

  • @GarethSomers
    @GarethSomers 2 ปีที่แล้ว +1

    At 5:45 you appear to add a SelectorComposite but don't mention it (afaik).

    • @bitbraindev
      @bitbraindev  2 ปีที่แล้ว

      Yeah, this is a small video script issue that I only noticed after uploading! We have to wrap it into a selector condition to make the entire condition work properly and I forgot to mention it during the recording.
      I hope the video makes sense regardless! Thanks for raising this. I will add a small footnote on the pinned comment!

  • @MrTony2371
    @MrTony2371 2 ปีที่แล้ว +4

    Thank you for your addon. It looks cool and promising. However, this tutorial doesn't help a lot in understanding the core functionality of behavior trees. it would be cool if there is a more detailed explanation of each step you've done.
    "Let's add SequenceStarComposite node..." - Why not simple SequenceComposite node?
    "Let's create similar setup for lumberjack" - *selects Selector node as a root, while in previous setup SequenceStarComposite was a root node* Why so?
    "...tree should be empty, except for the script..." - What exactly each line of the script does?
    "...tick the box for Access as Scene Unique names?" - Why? What does it actually do?
    And a lot of cursory staff about the topic. What's the point of making 10 min tutorial if the only thing it teaches is how to copy your actions to recreate the same scene you provided?

    • @bitbraindev
      @bitbraindev  2 ปีที่แล้ว

      My tutorials are less about teaching but more "Stackoverflow style" solutions to problems.
      People can always research the theory behind stuff thenselves - there are literally thousands of great explanations out there how behaviour trees work in theory. The aim of this tutorial is to actually use them in a game.

    • @MrTony2371
      @MrTony2371 2 ปีที่แล้ว +3

      @@bitbraindev I got your point. Anyway, Ill be trying to create ingame AI with your addon. Thank you!

  • @EnexileRaven
    @EnexileRaven ปีที่แล้ว

    Great video! Questions, it appears the assets are gray and blurry. what happened?

    • @bitbraindev
      @bitbraindev  ปีที่แล้ว

      The assets are paid and cannot be stored on Github, so you'll have to buy them if you want the original ones: danieldiggle.itch.io/sunnyside
      I will try to use free assets for future tutorials.

  • @Bargeral
    @Bargeral 2 ปีที่แล้ว +1

    The name "Beehave" does not show up in the godot asset store when searching Behavior or Tree. Might want to adjust it a bit. eg: Beehave (Behavior Tree)

    • @bitbraindev
      @bitbraindev  2 ปีที่แล้ว +3

      Great suggestion! Thank you.

  • @AdamBechtol
    @AdamBechtol 2 หลายเดือนก่อน

    Thanks.

  • @BartoszBielecki
    @BartoszBielecki ปีที่แล้ว

    Couldn't we add a tool based on node (like shaders) API?

  • @dbseraph
    @dbseraph ปีที่แล้ว

    is there a simple way to replace the grayscale assets from the project file with the color assets from your asset pack, or a guide for which ones to replace them with? the names don't seem to all match. also for the grayscale goblin anim sprite?

    • @bitbraindev
      @bitbraindev  ปีที่แล้ว

      I may need to write up a guide how to replace it. My future tutorials will use an open-source spritesheet/sprites that is not proprietary.

  • @Necrincito
    @Necrincito 5 หลายเดือนก่อน

    Hello, Tutorial system (trees) that fall when felling, with which the player plays the felling animation, when the number of times (felling) reaches the tree, it plays an animation that makes it fall and drop objects. Could you create a video tutorial, showing the entire procedure? please

    • @Necrincito
      @Necrincito 5 หลายเดือนก่อน

      Game 2d

  • @kunai9809
    @kunai9809 2 ปีที่แล้ว

    little question: can I count on you that you maintain this plugin and I don't have to worry that it will be unusable at some point? Or rather, how likely is that. I understand that you probably won't give any guarantees :D

    • @bitbraindev
      @bitbraindev  2 ปีที่แล้ว +1

      This plugin will be maintained long-term, as I am actively using it in my RPG which will be in development for many more years. Oh, and it also supports Godot 4 already!

    • @kunai9809
      @kunai9809 2 ปีที่แล้ว

      @@bitbraindev niiice

  • @ezenki9484
    @ezenki9484 2 ปีที่แล้ว

    what is this godot ui that you are using, great tutorial btw

    • @bitbraindev
      @bitbraindev  2 ปีที่แล้ว

      Here you go! github.com/bitbrain/godot-dash

    • @ezenki9484
      @ezenki9484 2 ปีที่แล้ว

      @@bitbraindev is it possible to install it without the steam version of godot or is it only available for the steam version

    • @bitbraindev
      @bitbraindev  2 ปีที่แล้ว

      @@ezenki9484 this should work for any Godot installation. If you have difficulties, please raise an issue on the Github issue tracker, please!

  • @WilsonSilva90
    @WilsonSilva90 ปีที่แล้ว

    The source code for the starting project is no longer accessible. Did you make it private?

    • @bitbraindev
      @bitbraindev  ปีที่แล้ว

      it should be accessible again! Had to do some changes to the assets! github.com/bitbrain/godot-tutorials

  • @sparky8251
    @sparky8251 2 ปีที่แล้ว

    I'd love to see a rimworld style behavior tree setup, where there is a global list of things to do and each villager will attempt to do them in a specific order based on user set priorities. Is that even something this addon can handle?

    • @bitbraindev
      @bitbraindev  2 ปีที่แล้ว

      Technically, yes. However, it would require an additional abstraction on the setup side.

    • @sparky8251
      @sparky8251 2 ปีที่แล้ว

      If you ever make a tut on it, I'd appreciate it at least :)

  • @JamesKelly89
    @JamesKelly89 2 ปีที่แล้ว

    I love your accent. I could listen to you reading the phone book (for Gen-Z: it's a literal paper book full of names and associated phone numbers).

  • @adamprogramming1111
    @adamprogramming1111 ปีที่แล้ว

    If i destroyed trees and went to another scene and came back they restore their state.
    How can i make them continue through changing scenes?

    • @bitbraindev
      @bitbraindev  ปีที่แล้ว +1

      You will need to build a savegame system! Or keep the scene in-memory.

  • @davisantos5672
    @davisantos5672 ปีที่แล้ว

    If I find this tutorial useful? I'd hug you

  • @xcoder2205
    @xcoder2205 ปีที่แล้ว

    When will there be a tutorial for 4.x?

  • @jazpaa
    @jazpaa 9 หลายเดือนก่อน

    This tool looks great, but I find the tutorial somewhat confusing, perhaps because it is so fast. Then again, I'm kind of a newbie, haha. An updated tutorial would be sweet though.

    • @bitbraindev
      @bitbraindev  9 หลายเดือนก่อน +1

      The tutorial certainly is not aimed at absolute beginners. I wish there was an easier way to highlight this. Perhaps I should start using terms such as 'Beginner' and 'Intermediate' in the video titles.

  • @horohoro1836
    @horohoro1836 2 ปีที่แล้ว

    Good work. Thank you ^^ (abo auch direkt dagelassen ;D)

  • @andrewgrinn3435
    @andrewgrinn3435 2 ปีที่แล้ว

    Nice

  • @sassafras2336
    @sassafras2336 11 หลายเดือนก่อน

    Any word on a 4.x tutorial? Love the plugin but struggling with limited resources as a newbie

    • @bitbraindev
      @bitbraindev  11 หลายเดือนก่อน +2

      There will be a 4.x tutorial, no idea when though.

  • @mohokhachai
    @mohokhachai 8 หลายเดือนก่อน

    I spent 5 years in Opsive studio

  • @mohokhachai
    @mohokhachai ปีที่แล้ว

    😎

  • @DenzelWashingMachine
    @DenzelWashingMachine 2 ปีที่แล้ว

    Works in 3.5 until the end. Lumberjack and Trader both have the proper .gd script but Forester does not have a gd script and uses behave root as default. The other two ai work as intended but the forester glitches out at front of his house. Not sure this is intended but otherwise good tutorial.

    • @bitbraindev
      @bitbraindev  2 ปีที่แล้ว +1

      This tutorial will not work with Godot 3.4.x and below, as it is using new components of 3.5 under the hood!

  • @KlausWulfenbach
    @KlausWulfenbach 2 ปีที่แล้ว

    So I installed 3.5 RC 7, and everything works pretty well.
    But I'm totally tattling to the other commenters that there's 40 leftover warnings by the end. Mostly "The argument 'blackboard' is never used in the function 'tick'. If this is intended, prefix it with an underscore: '_blackboard'".

    • @bitbraindev
      @bitbraindev  2 ปีที่แล้ว

      These warnings are normal and are purely about code style. Nothing to worry about.

  • @kerlisgray3539
    @kerlisgray3539 2 หลายเดือนก่อน

    I rreally like concept of making games but getting money from it is the difficult part.

  • @vinicios181000
    @vinicios181000 ปีที่แล้ว +1

    Thank you for the tutorial and the lib, however you go too much fast... Quick tutorials are great to explain simple things, but honestly I watch this video many times and just wasnt sucessfull to understand the whole thing

    • @bitbraindev
      @bitbraindev  ปีที่แล้ว

      Thank you for your feedback! In future, I will try to do less content per video but go slower/more in depth!

  • @jumpsneak
    @jumpsneak 2 ปีที่แล้ว +1

    Basicly reinventing programming for people who do not want to be programming in code