State Tree: How can I access parameters from outside the component?

Hi there,

WIth behavior trees, from any object I can access the current values from the blackboard component so long as I can reference the AIController:

I have recently switched to State Trees. How can I access the current parameters of a State Tree in asimilar fashion to the above?

You will need c++ to access parameters as they don’t seem to be accessible via blueprints from external sources.

You would probably need to extend StateTreeComponent.h to get access to the state tree reference where the parameters reside (the ref itself is protected so it’s not exposed by default)

image

from the reference you can access the parameters via GetParameters (StateTreeReference.h)

Hopefully Epic will expose the parameters from BP. For now you can only set them via BP.

1 Like

Hey,

I just gave this a go but unfortunately it provides me with the default values of the parameters. When they change during runtime the values here do not update, it continues to provide the default value.

image


(note, in my code here I was originally trying to get an actor from the Parameters using “GetValueObject”. I switched to getting a float to remove the step of casting from Object to Actor. I wanted to ensure that I could successfully get the parameter without the extra step that could possibly be cause for this being unsuccessful)

I can see there has been some updates in 5.6 so I’ll get round to checking that out though that doesn’t resolve this issue yet.

In case anyone from the future comes here, I’m yet to solve the problem but I got around it by creating a task that sets this variable in the class I required it.