Can you expose an actor's static mesh component straight to a State Tree Task?

Say you have an actor with a State Tree on it. Can be any actor. And one of the state tree Tasks needs one of the actor’s static mesh components.

Is there a way to pass the component directly to the State Tree Task? Thanks.

What do you mean by “Can be any actor?” It is obvious that it can only be the actor that has the State Tree component on it.

Anyway to set component parameters runtime you can check this discussion: How to assign StateTree parameters at runtime - #13 by The-JL

However, since you have your actor in your context you can actually get any component type from it. Moreover, since we established that the actor in the context is “TheActorWithTheStateTree” you can cast to it’s specific type and get all its custom variables and methods as long as they are public.

1 Like

I want to use this state tree on multiple types of actors.

I know I can “get component of class” from the context actor, but I thought maybe I’m missing a more direct way to just select the component straight from the details panel of the actor containing the state tree, by filling a parameter or something like that.

The thing is, if I have multiple components of a certain type in the context actor, I don’t know how to get just the one I need, in the state tree task.

Well, even if you could set it in the details panel (you can’t) it will be set for this actor type only so it won’t match your requirements.

If you want to attach it to arbitrary actors and it should just work “out-of-the-box” you should consider all variants even the variant where you attach it to an actor with no mesh component.

Well the fact that you are looking for a specific component among many tells me that this is not “any actor”. You have so many specific requirements that it seems that you just need to make a parent actor that has this state tree and derive your “any actors” from it as child blueprints.

This way you can actually cast to the parent class and get the specific thing you are looking for.

1 Like