Action System Demo
v1.0
This scene is not a game scene, really, it's a bit of a playground with a number of features that utilize Juicy Actions in neat ways that I think many devs will find useful.
Press play, and there's 3 things to click on, and a number of things to look at.

Character Sphere (Blue ball)
Start by clicking the blue ball, the Character Sphere. It flashes red and rotates. The object has an ActionOnTap component on it, which handles tap and clicks with the mouse.

The ColorChangeAction drives the red color β it turns red immediately and then will slowly fade back to the original color. The SpinAction drives the rotation.
The SpinAction is different from the RotateAction, and is intended for a visual "spin".

We have a 2 second duration, and the Speed Curve value speeds up over time, and then back down.
Click the Back Wall
Now, click anywhere on the black wall. The blue Character Sphere will move to that location with a MoveSpringAction. When the back wall is clicked, the Action Recorder object will record the position of the tap using the OnTapActions executor and the RecordTapAction.
This Action is one that utilizes the Action Blackboard. It can record the position on the blackbaord (and notify watchers), or send an event only. With the "Require Direct Hit" flag false, any tap on the screen will work β although in this case we also are ignoring when over UI.

The UI objects Last Hit Screen / Last Hit World / Last Hit Object update themselves using the TMPSetTextFromTapAction. This works together with RecordTapAction, to parse the structure into the text data.
The RecordTapAction and RecordMultiTapAction are powerful tools when used with the TriggerUnityEventWithTapData and TriggerUnityEventWithMultiTapData actions. They allow you to easily send screen tap / click data to other objects.
See the Character Sphere Move
When you click the wall, the Character Sphere will move to that position using a MoveSpringAction.
In the Character.cs class, we override OnBlackboardNotification and call DoMovement(tapData.worldPosition).
In the DoMovement() method we find a target position by getting a specific point that is between the camera and the world position tapped, based on the distanceFromCamera value.
We then override the MoveSpringAction target value β note we have exposed the string moveSpringActionName in the Inspector in this example, along with the targetPositionFieldName.
Finally, we execute the ActionExecutor set of actions. This includes a "Quick Spin" SpinAction, the MoveSpringAction, followed by a ScaleSpringAction scaling the sphere bigger, and then ScaleSpringAction scaling the sphere smaller, back to default size.
Action Cube
The Action Cube in the scene is a small brown cube. You can click this as well, or press the "Space" key to trigger the same effects. This is accomplished using a ActionOnKey component with a TriggerUnityEventAction that causes the OnTapActions from the ActionOnTap component to execute.
The ActionOnTap component has the OnTapActions ActionExecutor.

In this we have three groups, with a WaitRandomAction prior to the "Final Firework" group.


The Final Firework and Fireworks Group contain the same actions β a SpawnAction, PlayAudioClipAction, and SendBlackboardEventAction. These will spawn a particle while playing a sound, and sending an event to make the camera shake.
However, the Fireworks Group is set to loop 10 times. The timeBeforeNextAction is set to 0.2 for the SendBlackboardEventAction which means 0.2 seconds will pass before the execution list is completed β this means that it will trigger 10 times over 2 seconds. The Final Firework group will only execute once.

The Jump and Stretch group does three actions at the same time, making the cube move up (MoveAction) with a jump-like curve, stretch (ScaleAction), and spin (SpinAction).
Try clicking the cube while it is in the air. Actions have an OnRestart() method and are intended to be designed so that information from the first instance of the action, such as the original position or rotation, will be maintained by subsequent instances.
This means that no matter how many times you tap the cube while it is in the air, it will return to the original position and rotation that were there before the first execution on this group of actions.
Cactus Thing
There are a number of green objects which have an ActionRunner component on them. Each have a number of ScaleSpringAction actions, which have different target y values, separated by WaitRandomAction actions, with a value of 0.5 to 1.5 seconds. This allows the objects to have the same motion, but in a random pattern.
The first action is a WaitRandom, which means each object will start at a random time, and diverge more from there.
We hope that this demo scene has helped demonstrate the use of the RecordTapAction and how to use that data, along with the OnRestart() logic that actions are intended to utilize, for smooth restarting before they have finished their durations.
Last updated