Hi everyone
I'm trying to learn how to generate actions and action lists through scripts.
Related to this Object: Transform
GUI action shown in this picture: https://imgur.com/a/KvT4pIy
My question is, how can I write the same "translate by" action in code?
I noticed there is AC.ActionTransform.CreateNew(). But I don't want to use a marker. Instead, I want to translate it by some Vector3 value. Is there a simple way to do this?
It looks like you're new here. If you want to get involved, click one of these buttons!
Comments
Welcome to the community, @antakasa.
The CreateNew function can be used to generate an Action through script. Actions typically have multiple variants of this to allow for different parameters, but currently only the "Marker" variant you describe is available for ActionTransform.
I will see about adding new variants in the next release - thanks for the suggestion.
In the meantime, you can add the following to the bottom of the ActionTransform script (just beneath the existing CreateNew function) to give you the ability to create a "Translate By" Action:
Creating such an Action would then be a case of calling:
If your Vector3 variable is taken from a component Variable, you'll need to extract that variable's value and pass it into the moveAmount parameter, e.g.:
More details on scripting Actions can be found in the Manual's "Generating ActionLists through script" chapter, as well as with the ScriptedActionListExample script file included in AC's package.
This works perfectly, many thanks to you Chris!