Quick Start
v1.0
In this quick start tutorial we'll add actions to a primiative in the scene. This will demonstrate how to quickly add Juicy Actions to your project. The video corresponds to the written instructions.
Scene Setup
Create a new scene, and add a cube. We will make this character move using Actions. If you'd like, focus the camera and add a material to the cube.
Add an Action Runner
Add an ActionRunner component to the Cube. The Action Runner class contains an Action Executor, and can automatically execute the actions, restarting them when they complete.

Add an Action
In the "Actions" list, select an Action in the object field: Scale Spring. This action scales a Transform with a "Spring" feeling.

Once added, click the "Eye" icon to expand the Action. You'll find three sections: Overrides, Settings, and Conditionals.

Configure the Spring Scale Action
With the Overrides section visible, lets adjust the settings for this action. By default, all overrides are toggled off, and the settings on the Scriptable Object will be used. Toggle on the overrides for "Use Relative Scale" and "Target Scale"
Set "Use Relative Scale" to false, and the "Target Scale" to 2, 2, 2.

Collapse the action by clicking the "Eye" action, and then click the "Clock" button and allow the action to determine how long before the following action is triggered.

The "Time before Next Action" is NOT the same as the duration of an action that occurs over time. If the value in this section is 0, the next action will execute immediately after this one.
Duplicate the Spring Scale Action
Click the "Duplicate" button to dupcliate this action. The "C" button will copy the action into your clip board, allowing you to paste it into any other Action Executor in your project, retaining the settings.

Expand the new action, and set the "Target Scale" values to 1, 1, 1.
Finally, set the Time value to be "Unscaled", and ensure the Auto Start and Auto Restart values are true.

The "Time" setting determines which time system to use. By default, the JuicyActionsSettings file is configured to start the a timeScale of 0, meaning our actions would not actually run. We will select Unscaled since we will not be utilizing the Action Clock for this tutorial.
The Auto Start and Auto Restart options are part of the ActionRunner class, not the ActionExecutor.
Press Play to Test

Now our cube will scale with a "Spring" forever!
Slightly More Advanced Logic
Next, we'll create a custom class with an ActionExecutor that will move the object within a set area. This will also demonstrate how to inject data into Actions at runtime.
Create a class called JuicyQuickStart, and expose an ActionExecutor. Add this to the Cube in the scene.
In the Inspector, we can see the Action Executor ready to go. Set the "Time" option to "Unscaled" or "Unity Time".

Add a Move action
Add a Move action to the ActionExecutor. This action moves a transform over time. (or instantly, if you'd like).

Override the optoins in the "Move Settings" section as shown. Set the "Move Duration" to 0.33, and the Target Position to 0, 0, 0. We will be setting this at runtime via code.
Choose a Move Curve that starts at 0 and ends at 1, which represents the start position (0) and Target Position (1). Finally, set Use Relative Position to false.
Set a Bounding Area in the Scene
In the Scene, create a new Cube called "Bounding Area", and set the scale and position so that it fills most of the cameras view point. Then, remove the Mesh components from the cube. This will define the area that our Demo Cube may move to. Only a BoxCollider will be left on the object.
Add a reference to the BoxCollider component to your class, along with a KeyCode that determines the key we'll press to make the object move.
Next we'll code a simple method to find a position within the area, and a method to move the object. Pay attention to the Move() method, which calls the Execute() method on the ActionExecutor.
Inject Data into the Action
We need to set a new RandomPointInBox() result in the Move action on the moveActions ActionExecutor.
We can do this with the SetFieldOverride<TAction>() method. We will specify the MoveAction action, and we can see in the Inspector this specific field is called "Target Position", so we will set the fieldName parameter to targetPosition.
This is fine when there is only one MoveAction in the ActionExecutor. If there are more, we can use the uid value on the Action in the ActionExecutor list to specify which Action we are overriding.

Click the "Copy" button to copy the UID to your clipboard, then set the value directly in the SetFieldOverrideByUID() method.
By setting this before we call Execute(), the action will have an updated Target Position to use. This will be visible in the Inspector at runtime.
Press Play to Test

Now each time we press "Space", the cube will move to a new position. The ActionRunner continues to operate independently, scaling the cube up and down.
We could add more actions to the moveActions ActionExecutor. However we will end this quick tutorial here.
Takeaway
I hope this short tutorial demonstrated how easy it is to quickly add actions to your project. Juicy Actions is able to add simple juice to objects, or engage in complex game logic.
You can even create custom Actions that are specific to your project. Dig into that more in the Follow Along Tutorial Game, which goes more in-depth using a prototype game project.
Follow Along Tutorial GameLast updated
Was this helpful?