limbonaut / limboai

LimboAI - Behavior Trees and State Machines for Godot 4
https://limboai.readthedocs.io/
MIT License
1.07k stars 35 forks source link

Add `BTInspector` singleton, an in-game tool for visualizing BTs #81

Open limbonaut opened 5 months ago

limbonaut commented 5 months ago

Easy to use in-game behavior tree inspector, that would allow choosing a running BT instance.

Rubonnek commented 3 months ago

It seems to me BTInspector could be an external resource instead.

I already have a similar-ish BTInspector implementation in GDScript. It doesn't tap into the debugger and uses it's own implementation for an in-game scene tree. I've only tested this against the master branch of Godot and using LimboAI as a module. Not sure if it works with Godot 4.2.

Press F2 to bring it up: demo.zip

The user must find the BTPlayer node in the scene tree viewer in order to populate the BTView.

https://github.com/limbonaut/limboai/assets/8337880/9df4b05e-02d9-4f11-a0ce-50dccd9ce530

I've been wanting to rewrite my implementation as a module for PankuConsole but it doesn't have a scene tree viewer -- I was planning to use that to implement a PankuModule to view the BTPlayers.

limbonaut commented 3 months ago

I guess, by external resource you don't mean godot Resource, right? Tapping into debugger is mentioned by me from a practical perspective - the LimboAI debugger already knows about nodes that own BT instances (both BTPlayer and BTState). So you wouldn't need a SceneTree viewer then, or that data can be used to build a specialized viewer control. Would be nice to rework that registering mechanism to encompass also custom player implementations, either by providing an API to register running instances or perhaps encapsulate it using the BehaviorTree.instantiate func instead. Currently, the in-editor debugger only shows nodes that are explicitly registered with it (BTPlayer and BTState do that in DEBUG_ENABLED builds).

Rubonnek commented 3 months ago

I guess, by external resource you don't mean godot Resource, right?

Right, I should've said plugin.

Tapping into debugger is mentioned by me from a practical perspective - the LimboAI debugger already knows about nodes that own BT instances (both BTPlayer and BTState).

I see, I forgot about BTState being able to hold BTs. Tapping into the debugger makes more sense than I initially thought. For a second there I figured BTInspector on release builds would be a nice to have in case some memory corruption affects the BTs, but now I think it's not worth the effort.