Qriva / MonoBehaviourTree

Simple event driven Behaviour tree for Unity projects
MIT License
257 stars 19 forks source link

Improve blackboard variables #15

Open laicasaane opened 2 months ago

laicasaane commented 2 months ago

Some possible improvements:

  1. Allow copying selected variables from master blackboard to sub blackboards. To reduce the amount of manual typing and selecting variable type!
  2. Allow copying variable names. To support some other usecases where I need the names but typing them is a labour I want to avoid. The current workaround is opening the Inspector in Debug mode and looking for the component.
laicasaane commented 2 months ago

A thought on copying variables from master blackboard: maybe we can use references from the master instead of adding new variable components on the sub tree to reduce the amount of MBs.

Qriva commented 2 months ago

Hi

  1. Do you mean some spcial function like button/dropdown? How this would work?
  2. I understand this as making variable labels (names) as selectable, correct?

A thought on copying variables from master blackboard: maybe we can use references from the master instead of adding new variable components on the sub tree to reduce the amount of MBs.

Can you elaborate further?

laicasaane commented 2 months ago
  1. For example, my character has a master blackboard with many variables

image

And the "Attack" sub-tree needs many variables from the master blackboard (all, except the attack_input) image

So currently I have to do these steps to "copy" a variable from the master blackboard to this "Attack" blackboard:

So I imagine if we have a "Copy from Master" button that will be enabled if there is a reference to the master blackboard: image

This button will show a list of master variables, each with a checkbox, something like this: image

We choose the variables to be copied, click "OK" and then: a. New variable components will be added on the sub-tree GameObject and their references will be added to the list, or b. Only the references to the selected ones will be added to the list. No new variable component will be added on the sub-tree GameObject.

I prefer 1b because ultimately the variable list only stores the references: image

With 1b we can reduce the number of components on the sub-tree GameObject.

laicasaane commented 2 months ago
  1. There should be another menu item labeled "Copy Key".

image

Qriva commented 2 months ago

I admit that not being able to copy key is a bit bothersome, for me too and I guess the best option would be to make labels selectable, so it's possible to double click and copy name. I think I am going to check it soon.

When it comes to copy of variables from other blackbloard, it's not so complicated, but it requires more work, especially example with custom popup. I think it's good feature when seen in the current context (state of tool), but I don't think I have time to revisit this problem right now. To be honest the current implementation of subtrees and their blackboards is really clunky 😅

Qriva commented 2 months ago

I wanted to make the label selectable, however I encountered small problem. Selectable label has no tooltip and I use it to display variable type on hover. For this reason I added "Copy Key" in dropdown, but It would be better to implement this a bit better. On top of this I added option in component menu to "Log Variables" and it lists all variables in the console: obraz b79b1b809999fe5fcf7b88d0d67417159a2e37a3