bitbrain/beehave

Debug view in editor

bitbrain opened this issue ยท 11 comments

Is your feature request related to a problem? Please describe.
When running games with behavior trees it is difficult to follow what is currently happening within it. Setting breakpoints within individual nodes is not ideal and when there is a bug it is quite difficult to figure out which nodes of the tree are currently running and what status they are currently in.

Describe the solution you'd like
Introduce a visual view inside the editor when clicking on a behavior tree that renders the behavior tree visually and highlights the status of every node in the tree and the "flow" animated as well.

Example from Tomate_Salat

Harvest02.mp4

Could the debug view be drawn with the _draw function by the root node? It'd be easy to enable/disable "debugging" with the node's visible property (somehow it'd have to default to disabled), and you could draw the behavior trees in the game world as the game runs. Would be cool to see the states highlight and change

@GammaGames that is an interesting idea. I was more thinking about having it as a dedicated node scene (with Godot 4 you could have it as a separate window next to your game).

The problem with showing it "in the world" is that especially for pixel art games, the camera zoom makes it very difficult to properly show the behaviour tree.

I agree that a separate scene would be easier, and you could always throw it inside a viewport to render it in game

And yay, separate windows!

What's the state of this? Debugging without this is really painful.

@GammaGames worked on a Proof of Concept in the past (see GammaGames#1). Unfortunately, that solution was flawed due to the following:

  • someone using this addon should not have to setup additional stuff to get debugging to work. It should just work
  • there were some API breaking changes we had to do in order to cater for the debugging functionality. With the 4.x branch we may get away with it (since Godot 4 is officially not out yet)

The important thing is that there needs to be three things to make this work:

  1. a dedicated debug view inside the Godot editor (perhaps in a new tab or when clicking on a behaviour tree node?) that displays the whole behaviour tree and shows the status of each node (e.g. by using colours, @GammaGames did a good job at that in his first attempt)
  2. theming support: the BeehaveDebugControl should be a component that works like any other component in Godot and the colours/font should be "agnostic" to the current Godot theme.
  3. That BeehaveDebugControl should define something like this to allow people to reuse the debug component ingame and display it while the game is running:
@export var tree:BeehaveTree

By default though, I would expect this debug view to "just work" inside the Godot editor. Something like a "test mode" might also be useful #84 (that could come later though once the debug view is done). I could imagine a "play button" to test the behaviour tree in isolation inside the Godot editor without the need to start the game itself (similar how AnimationPlayer works now)

That all being said: feel free to raise a PR and implement it!

What do you think about this concept? :)

Godot_v4.0-beta17_win64_p5Y4QS5nxM.mp4

@DarkMessiah that looks so good, wow. Do you have a branch I could checkout to test it? (or even a draft PR?) ๐Ÿ‘€

@bitbrain right now, it's just visual without any logic :) I need a bit more time to make it real ๐Ÿ‘€

@DarkMessiah looking forward to it! Give me a shout if you need any help.

@bitbrain Sharing some progress. Now it's a working prototype! ๐Ÿ˜Ž

Godot_v4.0-rc1_win64_Oz06D7pJqm.mp4

@DarkMessiah great progress! Cannot wait for that PR to have a play with. ๐Ÿ‘Œ๐Ÿ‘