Add a moderately simple behavior tree example
I really want to give beet a go for BTs but the example and the docs don’t really tell me enough to know what it’s doing. My BT knowledge is definitely new, that’s for sure, but I was able to get further with bevior_tree than beet.
An example like the one in bevior_tree would be great if you’re interested in adding one?
Alternatively, maybe you already have some more than basic code using beet that you can refer to?
Thanks for the feedback yeah the examples could use some work to describe whats happening and a lot of them are kind of jumping the gun on scene based workflows so the files are spread out.
At a glance the bevior_tree example looks most similar to seek_3d which has a seek/arrive sequence.
- Source code for the tree: here
- Command:
cargo run --example seek_3d
Also in case you missed it this quick start is an attempt to describe the internals, I'd appreciate hearing if you think some part of that could also use more clarification.
Ah cool, I will check out the seek_3d code in detail. I did open that and saw this:
https://github.com/mrchantey/beet/blob/01f4c6a4063cc3976644dfebe0aeb6447df96891/examples/seek_3d.rs#L10-L14
And was a bit "turned off" so I don't think I actually looked further on this example...
I am vaguely aware that you're working on some scene stuff, so its not up to me to say how you should design your examples, but as a user going to beet, the first thing I do is go to the examples folder and open up some of them. When I see the scene and helper systems indirection, it makes it harder to understand what the example is doing (because the example.rs is 100% now just an entry point). The scene indirection specifically also makes it harder to understand and it's not going to be relevant to every user. Not sure the best solution there, but you could consider keeping the scene-based ones in a separate folder and keep the root ones "pure" for the crate they are example-ifying. Re the calling out to helpers, that's a tricky one. I know https://github.com/vleue/vleue_navigator/blob/3e2c68c590eda67bb98cf325e1854ec51627362c/examples/demo.rs#L56-L69 does it too, and it's a balance between the crate author wanting to reuse helpers (which users can also take and reuse), vs describing how stuff works inline.
Re the quick start. I did go through it originally (I think) a couple of months ago though but maybe it's changed. One initial reaction when going through it the first time (and from the example in the repo), is that for some reason "log on run" just doesn't click with me. I get that ultimately the log statement just represents doing something, but if there was any more to use something closer to in-game logic, I'd opt for that.
Experience report from bevior_tree:
- I opened it and ran the example.
- I looked in one file and started reading the code for it—all the code for it is in the one place.
- I copied the example to
chase2.rsand started modifying it / playing with it. - I fiddled with returning pending, or success or failure, or changing to a selector rather than sequence, etc.
- I continued doing that until I got up to
chase4.rsand it was great for experimenting and also learning what the crate can do.
Based on that experience, the most obvious thing I'd get value from (personally) is an example all in one file, even if it's the seek_3d one—and running it now, I can see that it does look (more than) moderately simple which is good.
consider keeping the scene-based ones in a separate folder and keep the root ones "pure" for the crate they are example-ifying.
That makes a lot of sense, pretty much all the helper stuff is rendering related, ill look into seperating into examples/logic/.. and examples/rendering/...
Re the quick start... if there was any more to use something closer to in-game logic, I'd opt for that.
Great feedback it sounds like the quick start should be closer to a walk through of your experience getting started with bevior_tree, and the current one could be renamed to the Action macro or something.
Ive added two examples:
- Vanilla Bevy is a minimal demonstration of how beet works without using the library.
- Malenia is a moderate example that uses both behavior trees and utility ai
I'll keep this issue open until I get around to updating the quickstart.