meniku / NPBehave

Event Driven Behavior Trees for Unity 3D
MIT License
1.15k stars 195 forks source link

Better Debugger vizualization #5

Closed Xerios closed 7 years ago

Xerios commented 7 years ago

I've been using https://github.com/dkoontz/BehaveN for my test projects and recently I've stumbled upon this beauty of a project. Nice work I gotta say !

Have you considered using UniRx for its reactive properties?

Anyways, I decided to give your debugger some "oomph" I hope you'd appreciate. npbehave

Xerios commented 7 years ago

PS. Add an image to your readme file so that unitylist.com can provide your repo a better discoverability 👍

meniku commented 7 years ago

Oh thanks, I'm glad you find NPBehave useful.

UniRx looks interesting. I worked with a FRP in the past, but didn't consider it in Unity until now. When I have some free time I'll check it out. I'm not sure whether I will add it to NPBehave though. It would mean a new dependency to a third party library and I want to keep NPBehave as simple to use as possible.

Your debugger looks amazing! Thanks for the great work! Do you have any idea how to get the "stop-button" working? I would not like to loose that feature, as it helps to detect problems in the tree.

Xerios commented 7 years ago

The button was there, but commented out and in image form. Unfortunately it would expand beyond scroll width of the component and mess up the inspector's layout view from time to time. I've changed it back to a normal small button.

Speaking of UniRx, I understand the concern for having additional dependencies and if you think it's not necessary then leave it as it is. Perhaps once Unity's Mono runtime has been properly upgraded you could try using the real deal (Rx.NET) :)

Xerios commented 7 years ago

Another thing.

What do you think of having a label for the nodes? This would help debug the bt better

image

My current minimal code affecting approach is like this: new Action(() => SetColor(Color.yellow)) { Label = "Change to Yellow" }

but I think something like this would be more preferable (same way as BehaveN does it): new Action("Change to Yellow") { Tick = () => SetColor(Color.yellow) }

This way all nodes can have labels and you get to more freedom to setup your nodes, like for example a WaitUntil node would be setup like this: new WaitUntil("Cooldown") { Time = 100 } new WaitUntil { Random = true, RandomFrom = 70, RandomTo=100 } // Label can be omitted

Xerios commented 7 years ago

Just another improvement, this is basically what I wanted to achieve in the beginning: image

meniku commented 7 years ago

new WaitUntil { Random = true, RandomFrom = 70, RandomTo=100 }

Oh that syntax to define the properties is pretty cool. I didn't know that is possible. That way we could reduce those constructors to one constructor per node type ( one thing that bothers me ) and the trees would also look much better.

Regarding the "Label": I had the Name property in mind for this at first, but I like your approach to keep the Name for the node-type and having an additional Label property.

I will merge your debugger changes. Thanks a lot

Xerios commented 7 years ago

Well I was thinking for the name property you could simply get it from the class name unless it's manually specified, instead of defining it for every class. But then again, that's just small details.

Anyway, I've been expanding the idea for a better debugger and this is where I got so far.

image

I'm still playing around with the design and colors, seeing what would be the best for user experience so no worries about that screenshot.

I'd like to help you make this library as great as possible, and I hope you don't mind me doing these changes without actually really knowing what you have planned.

meniku commented 7 years ago

Actually my plan is to apply changes as needed. Right now I am not working much with it, so progress is pretty much starving from my side. I will continue on it when I actually do more AI work.

I am very happy with any kind of contribution, as long as it makes the library better. Having a better debugger is such a thing. As long as it's ok for you that the contributions published under MIT license.

I really like the way you are improving the debugger, please go on with it! :)