Hello,
I am trying to write a custom action which operates on a particular type of component. The main question is: how do I get a handle on the component instance?
The easiest solution would be to pass an "owner" GameObject either as a value or as a variable and use the GetComponent method on it from within my script. However, if an object can have multiple instance of the component, then that approach won't work.
Alternatively I would like to specify the component itself, perhaps as a variable. There is no variable type for components, but there is FsmObject for objects and I can use the ObjectType attribute to specify the exact type. That sounds like what I need. However, how can I get the component instance? There is an AddComponent action and it has a "Store component" field, but I cannot select any variable to store the result in. All I see when I open the dropdown menu is "None". I have created an object variable, is there anything else I need to do?
Here is how I imagine it would work:
public class SetFooProperties: FsmStateAction {
[ObjectType(typeof(Foo))]
public FsmObject foo;
public FsmFloat bar;
public override void OnEnter() {
foo.Value.bar = bar.value;
}
}