limbonaut / limboai

LimboAI - Behavior Trees and State Machines for Godot 4

Home Page:https://limboai.readthedocs.io/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

limbonaut opened this issue · comments

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

  • Intended to be used as an in-game tool.
  • Taps into debugger to display a list of currently active BT instances.
  • As easy to use as a GDScript one-liner BTInspector.show().
  • Allow specifying which instance to display from code: BTInspector.inspect(bt_player.get_tree_instance()).
  • As a plus, allow registering/unregistering instances with the debugger for custom player implementations.
  • Using Window would allow moving the inspector view around, or popping it out in its own detached window.
  • Should only be included in debug/tools builds.

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.

demo.mp4

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.

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).

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.