godotengine / godot-proposals

Godot Improvement Proposals (GIPs)
MIT License
1.16k stars 97 forks source link

Add behavior tree functionality for AI #281

Open wijat opened 4 years ago

wijat commented 4 years ago

Describe the project you are working on: I am making a level pass level game, have AI enemy and BOSS

Describe the problem or limitation you are having in your project: Unity and Unreal have AI Behavior Tree Editor, I come from Unreal, It is very important for a game maker to make a complex AI. Now I can only use plugin for this feature. Create an Editor to let game maker more easy to manager their Behavior Tree nodes.

Describe how this feature / enhancement will help you overcome this problem or limitation: If Godot has some kind of AI Behavior Tree Editor, It will more easy to make AI and change AI logic.

Show a mock up screenshots/video or a flow diagram explaining how your proposal will work: external-content duckduckgo com

Describe implementation detail for your proposal (in code), if possible:

If this enhancement will not be used often, can it be worked around with a few lines of script?: You can make it by script but should make many lines to do it. And cause a big mess up.

Is there a reason why this should be core and not an add-on in the asset library?: It is very often meet when you make a game AI.

golddotasksquestions commented 4 years ago

User FruitPunch on Discord just posted this Behavior Tree addon: https://www.youtube.com/watch?v=RD0v25tORYo https://github.com/fian46/addons-btree

HeadClot commented 4 years ago

This would be really helpful for my game. :)

Jummit commented 3 years ago

I made a bevavior tree plugin that stays very close to Godot's design: https://github.com/Jummit/behavior-tree The UI is basically a clone of the visual shader UI. Maybe it could be used as reference if someone wants to implement it in C++.

warriormaster12 commented 2 years ago

Hi, I'm currently working on an ai behavior tree. At the moment I'm recreating this (https://github.com/kagenash1/godot-behavior-tree) plugin's behavior in C++ but I had a plan to also add the visual graph for it once I've done replicating the logic.

https://github.com/warriormaster12/godot

hopefully people will find this useful.

warriormaster12 commented 2 years ago

Quick little update, I've managed to replicate sequencer and task nodes. So far everything is going nicely.

HeadClot commented 2 years ago

Quick little update, I've managed to replicate sequencer and task nodes. So far everything is going nicely.

Do you plan to merge this with godot 4 master?

warriormaster12 commented 2 years ago

@HeadClot yeah, that was my plan. Hopefully it gets approved by the maintainers

HeadClot commented 2 years ago

@HeadClot yeah, that was my plan. Hopefully it gets approved by the maintainers

Ok, Cool. Let me know when you make a PR for it. I am over here cheering you on because this is very much needed in Godot engine :)

warriormaster12 commented 2 years ago

I'll let you know :)

GeorgeS2019 commented 2 years ago

@warriormaster12 Do you think this will support Godot to scale to complex behaviour?

warriormaster12 commented 2 years ago

Maybe it could. At the moment though I want to try how it would work out by using Godot's nodes as states. If performance is going to become an issue with this method then integrating this library wouldn't be a bad idea.

warriormaster12 commented 2 years ago

@HeadClot or anyone else in here, could you help me test the behavior tree out? I want to know how much stuff there needs to be done before it is stable/feature complete.

I'd love to provide a build but for some reason github won't allow me to post .zip files.

Calinou commented 2 years ago

I'd love to provide a build but for some reason github won't allow me to post .zip files.

This is likely because the ZIP file is likely larger than 10 MB. As a workaround, you use GitHub Releases (which allows files up to 2 GB) or push it to a throwaway Git repository (which allows files up to 20 MB).

warriormaster12 commented 2 years ago

https://github.com/warriormaster12/godot/releases/tag/behavior_tree

Here you go

fire commented 2 years ago

I might miss the proposal review, but I have support for this.

fire commented 2 years ago

Can someone post some visuals of the behaviour tree ai and comment which branches are synced with master? Trying to get some support from the core developers.

Calinou commented 2 years ago

We discussed this proposal in a meeting. We think that having this developed as a GDExtension makes the most sense for now. Once the extension is well-developed and there is enough user demand for it, it can be moved as a core module. GDExtensions can be compiled as static C++ modules with #defines (and vice versa), making this a straightforward process.

2plus2makes5 commented 2 years ago

I have never used a behaviour tree so i don't know much but i saw this video tutorial: https://www.youtube.com/watch?v=n0gVEA1dyPQ

for this plug-in: https://github.com/bitbrain/beehave

I don't know how good it is but from the video it looks simple, well done and i really like that it uses nodes instead visual nodes-like, i find it more compact, clean, more "Godot" and well a scene is structured like a tree so why not taking advantage of it?

shiouhuamien commented 2 years ago

我從來沒有使用過行為樹,所以我不太了解,但我看到了這個視頻教程: https ://www.youtube.com/watch?v=n0gVEA1dyPQ

對於這個插件: https ://github.com/bitbrain/beehave

我不知道它有多好,但從視頻來看,它看起來很簡單,做得很好,我真的很喜歡它使用節點而不是視覺節點,我發現它更緊湊、更乾淨、更“Godot”,而且場景是結構像一棵樹,為什麼不利用它呢?

The meaning of visual behavior trees and state machines, Even in complex AI, you can see the global dynamics at a glance, without searching, scrutinizing, imagining, recalling, The stacking tree can only be seen immediately in simple AI, The complex AI stacking tree loses the meaning of visualization, If you want to look for the reasoning line by line, just look at the code directly.

CsloudX commented 1 year ago

IMO, Terrain Editor, Behavior Tree all should be Engine's core features.

MBoqui commented 1 year ago

@warriormaster12, are you still working on this?

I am interested in working on this and have developed a Behavior Tree plugin in GDScript. Have also started porting it to GDExtension a while ago. I was about to try that porting process again when I found this issue. Thought of joining forces if there is already someone on this.

warriormaster12 commented 1 year ago

@MBoqui no I'm not actively working on a behavior tree but what a lucky coincidence, I was actually asking if beehave plugin's creator was interested in porting beehave to GDExtension bit by bit.

warriormaster12 commented 1 year ago

https://github.com/bitbrain/beehave/discussions/222

Checkout this discussion

limbonaut commented 8 months ago

I've been working on LimboAI, a C++ plugin for the Godot Engine that includes behavior trees and state machines. It can be used as a GDExtension library or as a Godot Engine module. LimboAI comes with a behavior tree editor, visual debugger, documentation, awesome demo project, a tutorial, and more!

Check it out here: https://github.com/limbonaut/limboai

https://github.com/godotengine/godot-proposals/assets/2766569/870d1af7-6258-42ee-a07c-8e27a8505b47