GameActions is a set of easy to use Unity scripts that can be used to reduce custom scripts that do basic operations like moving objects. It simplifies basic actions and makes them modular in a way that they can be created or modified in the scene without editing a script.
Checkout the Examples to get started. Here's some brief info.
An action instance does something when its Act or StartActing method gets called. An action acts only when it's enabled and its object is active.
These are actions that call the Act method of the actions in their level-1 children, all at once (Action Set), one by one in order (Action Sequence), or one of them randomly (Random Action Set).
Example: AnimatePositionAction
These actions animate a property from their current value to the Target value in the specified Duration (in seconds).
Animations with the Duration set to 0 will set the property to the Target value immediately.
Waits for the specified Duration. It's useful when we want to put delays in procedures (Sequences).
Forwards its action to the specified Action.
It can be used to create an action (which can be a set/sequence itself) and share it between multiple actions,
in this case a ForwardAction can be added to each that points to the shared action.
Loads the specified scene in SceneName.
Plays one or more audio clips on the Target's AudioSource. Just plays the AudioSource if no audio clips are specified.
Plays the Target's ParticleSystem.
Sets the Target object's activation state to the specified ActivationState.
Stops the specified Action.
Toggles the Target object's activation state. It will be false if it's currently true, and true if it's currently false.
When enabled and its object is active, loops the specified Action.
This is the main point of GameActions, simplifying actions. These are the steps to do this:
- Add a field with type
GameActionin your script, for examplepublic GameAction ExampleAction. - Call
ExampleAction?.StartActing();to start it and continue, orawait ExampleAction?.Act();to wait until the action is done. - In the scene, after creating your action (which can be a set/sequence), drag it to the
ExampleActionfield in your script.