beehave icon indicating copy to clipboard operation
beehave copied to clipboard

Debug view in editor

Open bitbrain opened this issue 1 year ago • 3 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.

Simplified example:

selector3

bitbrain avatar Jul 18 '22 16:07 bitbrain

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 avatar Jul 30 '22 06:07 GammaGames

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

bitbrain avatar Jul 30 '22 18:07 bitbrain

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!

GammaGames avatar Jul 30 '22 18:07 GammaGames

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

Wichamir avatar Dec 20 '22 10:12 Wichamir

@GammaGames worked on a Proof of Concept in the past (see https://github.com/GammaGames/beehave/pull/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 https://github.com/bitbrain/beehave/issues/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!

bitbrain avatar Dec 20 '22 11:12 bitbrain

What do you think about this concept? :)

https://user-images.githubusercontent.com/1756388/216330870-d3acefc2-f121-4d5f-b6a1-e2661cf8b6ab.mp4

DarkMessiah avatar Feb 02 '23 12:02 DarkMessiah

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

bitbrain avatar Feb 03 '23 08:02 bitbrain

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

DarkMessiah avatar Feb 03 '23 09:02 DarkMessiah

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

bitbrain avatar Feb 03 '23 10:02 bitbrain

@bitbrain Sharing some progress. Now it's a working prototype! 😎

https://user-images.githubusercontent.com/1756388/218341748-c8197b07-59b4-4ed2-ac2b-eeb3ff9f73b0.mp4

DarkMessiah avatar Feb 12 '23 22:02 DarkMessiah

@DarkMessiah great progress! Cannot wait for that PR to have a play with. 👌👍

bitbrain avatar Feb 12 '23 22:02 bitbrain