How to assign StateTree parameters at runtime

As far as I know, parameters are “set once, read only” data. If you want runtime parameters, you have to

  1. Make a task, global task or evaluator where the variable will be calculated.
  2. Make your variable in this object.
  3. Make it instance editable (click on the eye), or in C++ make it VisibleAnywhere or EditAnywhere (I believe either should work)
  4. Move it to the Output category. It must be spelled correctly, it won’t work otherwise.
  5. Add the task or evaluator object to the tree. If you did everything correctly, you should see a gray bubble saying OUT and you won’t be able to bind to this variable (since you’ll be writing to it)
  6. Set this variable only from this object.

Other tasks and evaluators can then bind themselves to read from this variable.

This is a poorly documented feature, but I got it to work doing these steps.

1 Like