New blog-based website ! Currently you are browsing the old site.

Creating reuseable behaviours

 

level: advanced beginner
requirements: virtools dev 2.1


Hi,

a behaviour engine opens the door for creating reusable components to a great degree.

Create once - reuse in many different contexts.

Of course designing for reuseability takes more time to develop then just going for 'one purpose/it's only here' design.
But the time one has to put into it at the beginning, pays off later easily after reusing it a couple of times.
Keep in mind not to try to create a thing that will fit for every situation etc and create not a thing that is able to do everything, or you will never finish!!!

So here are some thoughts on how I start working on such a behaviour.

Behaviour Graphs are the thing which can contain your logic and which you can save and load to/from the data resources.
Therefore start with it !!!!
Press 'g' and draw your new graph.


The reason why to start with the BG (behaviour graph) right from the beginning is, that if you later want to
encapsulate your logic into a BG you often need to rewire/relink a couple of parameters which simply cost some more time you could better spend for other things.

There's another reason why to start with creating a BG ...
but first click on the BG to set it into focus and press F2 and rename it.

The next step is to create the BG's inputs, outputs and it's input- and output parameters.
This is the second reason to start with a BG: it makes you think about what you need (in) and what you want (out)!

Use 'i' , 'o' and 'alt+i' , 'alt+o' or the context menu to create the BG/context interfaces.
My first input parameter now is often a 'target' input - in order to represent the targetable functionality.
So if you want to create a behaviour for 2D Frames, create an input for 2D Entities and call it 'target'.
The user has now the choice to stich a 'this' parameter to it, or something else.

Rename input and outputs (focus and hit F2 or context menue) with for-everybody-easy-to-understand-phrases. Don't worry if they are longer than one word. This way you or other don't spend their time thinking:
"Damn, for what was that 'cb_xK2l' float input for??!!". ;)

Ok now to my last step in my BG-Creating-Routine...
If you know you will create a larger/complex BG, store all your input parameter values into local parameters, first!
In combination with parameter shortcuts, it will prevent having blue dotted link lines going from the other side of the BG to the input parameters.
The BG will look cleaner and will be easier to understand and easier to modify!

So the picture above shows an example how I did it ... til now ... ... yes I'll explain soon ... :)
I also added a short cut - just to show it.

Now let's have a look at the 'identify' behaviour ... it has a 'v' on it - which stands for 'variable configuration'.
What does it mean?
Well, we can construct input and output parameters on this behaviour.
It's a shame that I did not discover/see that earlier! 8-|


This way we save some links! More power for the cpu left ;) ...

To resume:

  • start with a BG
  • create all interfaces (inputs, outputs, in- and out-parameters)
  • use easy-to-understand-names for important elements
  • store input parameter values right at the begining into local parameters when not working with very small BG
  • one never stops learning - even about basics !!!! ;)

Hope you found this interesting!
Any remarks/comments are welcome...

Greetings
Dominique