Behavior Examples

The following examples illustrate different ways that groups of behaviors can be combined to create different effects. The first three examples use content available in Motion, so, if you want, you can follow along.

Example 1: Using the Gravity and Edge Collision Simulation Behaviors

Gravity makes an object fall over time at a rate specified in the Acceleration parameter. Unless other behaviors such as Edge Collision are also applied, the object falls off of the bottom of the Canvas (or moves beyond the top edge of the Canvas if a negative Acceleration value is used). In this example, a group comprised of three layers (star shapes) is used to illustrate the Gravity and Edge Collision behaviors.

Note: Although you can apply the Simulation behaviors to single objects, their strength is in using groups of objects. Some Simulation behaviors, such as Vortex, require the existence of another object in a project to have any effect. For example, an object with an applied Vortex behavior needs another object to circle around it; an object with an applied Orbit Around behavior needs an object to orbit around.

In this case, Gravity is applied to a group that contains three layers (semi-transparent, colored stars).

To use the Gravity behavior
  1. Drag the “5-sided star” shape from the Library (in the Shapes category) to the Layers tab or Canvas.

  2. Press Command-D two times to create two copies of the star.

  3. If you’d like, modify the color and opacity of the stars.

    For more information on modifying shapes, see Shape Parameters.

  4. In the Layers tab, double-click the group that contains the stars, type “Stars” in the text field, then press Return.

    The group is renamed Stars.

  5. Apply the Gravity behavior to the Stars group.

    Figure. Layers tab showing Gravity behavior applled to Stars group.

    The animation path created by the Gravity behavior appears in the Canvas, and the group of stars falls when you play the project. Because the behavior is applied to the group, all layers in the group fall at the same rate.

    Figure. Canvas window showing the animation path created by the Gravity behavior.
  6. To increase the rate of the falling layer, drag the Acceleration slider in the Gravity HUD or Inspector toward the right (this example uses an Acceleration value of 100).

    Note: You can enter a negative number in the Acceleration value field in the Inspector to make the layer float upward rather than fall.

To use the Edge Collision behavior
  1. Apply the Edge Collision behavior to the Stars group.

  2. In the Edge Collision HUD (or Inspector), make sure the Affect Subobjects checkbox is deselected.

    When the Edge Collision behavior is applied to a group, and the Affect Subobjects parameter is turned off, the entire group is “bounced” off the bottom of the screen at the anchor point of the group.

    Figure. Canvas window showing the effect of the Edge Collision behavior.
  3. In the Edge Collision HUD (or Inspector), select Affect Subobjects.

    Note: The Edge Collision behavior Inspector parameters also include Active Edges controls for turning on and off the edge of the screen (or Z space) against which an object collides. By default, an object is deflected from all edges of the screen.

    When the bottom edge of each star hits the lower edge of the screen, the star is deflected and bounces upward.

    Figure. Canvas window showing how each object in the group responds to the behavior individually.

    As the project plays, each star bounces up and down.

    Other Simulation behaviors that also use the Affect Subobjects parameter include Align To Motion, Drag, Gravity, Random Motion, and Rotational Drag.

Example 2: Using the Orbit Around Behavior

The Orbit Around behavior makes an object orbit around another object in a perfect circle. The parameters of the Orbit Around behavior can be modified to create a more interesting animation.

You create animation using the Orbit Around behavior by specifying a target object that other objects circle around. You set the target object by dragging the object to the Object well in the Orbit Around Behaviors tab.

To use the Orbit Around behavior
  1. Using the result of the previous example, delete the Edge Collision and Gravity behaviors from the project.

  2. In the Layers tab, click the Add button (+) to create a new group, then rename the group “Center.”

  3. Option-drag the one of the stars to the new group.

    A copy of the layer is added to the group.

  4. Rename the copied star “center star,” then position the star in the center of the Canvas.

    Figure. Canvas window showing two groups of stars.
  5. Apply the Orbit Around behavior to the Stars group.

    The Orbit Around behavior is applied to the group of stars (“Stars”) in the project. The center star in the center of the Canvas is in a separate group from the rest of the layers.

    Figure. Layers tab showing Orbit Around behavior applied to Stars group.

    When the Orbit Around behavior is first applied, no animation occurs. This is because you must specify the layer that the group will orbit around.

  6. Drag an object, in this case the “center star” layer, from the Layers tab and drop it in the Object well of the Orbit Around HUD or Inspector.

    This object becomes the target object around which the other objects orbit.

    You can alternately drag an object in the Layers tab onto the Object well of the Behaviors tab.

    Important: Dragging an object to a well may be tricky—be sure to click the object name in the Layers tab and immediately drag the layer to the Object well (without releasing the mouse button). The behavior must remain active even though you are clicking another object in the Layers tab. If you click the object you want to drag to the Object well and then release the mouse button, that object becomes selected, and the behavior’s parameters are no longer displayed. This is true of all wells, including Mask Source and Image wells. To show the Orbit Around behavior parameters again, select the Orbit Around behavior.

    Figure. HUD showing an object being dragged to the Object image well.
  7. In the Orbit Around HUD (or the Inspector), make sure Affect Subobjects is selected.

    When Affect Subobjects is selected, objects within the group move individually around the target object.

    Figure. Canvas showing efffect of the Affect Subobjects setting.

    Other Simulation behaviors that also use a target object include Attracted To, Drift Attractor To, Repel From, and Spring.

Example 3: Using the Vortex Simulation Behavior

The Vortex behavior is the opposite of the Orbit Around behavior—Orbit Around causes one object to orbit around another target object, whereas Vortex exerts a force on all objects surrounding the object to which the Vortex behavior is applied. You can specify whether All Objects, Related Objects, or Specific Objects are affected by the Vortex.

The following examples use the same group of layers (stars) used in Example 2: Using the Orbit Around Behavior. For this example, the layers are repositioned in the Canvas.

To use the Vortex behavior
  1. Using the result of the previous example, delete the Orbit Around behavior from the project.

  2. Apply the Vortex behavior to the “center star” layer in the Center group.

    Figure. Layers tab showing Vortex behavior applied to the "center star" layer.

    By default, Related Objects is selected in the Affect parameter of the Vortex behavior. When Related Objects is selected, all objects that exist in the same group as the object to which the behavior is applied move around that object. Because the star is the only object in the Center group, nothing happens.

  3. In the Vortex HUD or Inspector, choose All Objects from the Affect pop-up menu.

    Figure. HUD showing options in the Affect pop-up menu.

    When All Objects is chosen, all objects in the project—regardless of the group in which they exist—are affected and move around the object to which the Vortex behavior is applied.

    Figure. Canvas showing Vortex affecting all objects.

    Note: If you have a layer that is center-aligned with the layer that has the applied Vortex behavior (the gradient background in this example), the aligned layer is not affected by the Vortex behavior. Once you offset its position, the layer is influenced by the Vortex behavior.

    Using the Vortex behavior, there are two ways to create an animation in which only certain objects (not every object in the project) swirl around the object with the applied Vortex behavior:

    • Set the Affect parameter to Specific Objects and select each layer that you want to swirl around the target layer.

    • Move the object with the applied Vortex behavior into the same group as the star layers, and set the Affect parameter to Related Objects.

To affect only Specific Objects
  1. In the HUD or Inspector, set the Vortex Affect parameter to Specific Objects (without moving any layers).

  2. If it is not displayed, show the Behaviors tab in the Inspector.

    In the Vortex parameters, an Affected Objects list appears.

  3. To apply the vortex to specific objects, drag the objects from the Layers tab to the Affected Objects list. Like the Object wells, you can drop the object when the curved arrow appears above the list.

    Figure. Behaviors tab showing a layer added to the Affected Objects list.

    As layers are added, the names of the objects as well as the group in which they exist appear in the list. When a group is dragged to the Affected Objects list, all layers within that group are added to the list.

    Figure. Behaviors tab showing Remove button for Affected Objects list.

    Note: Objects from any group in a project can be dragged to the Affected Objects list. To remove an object, select the object in the list and click Remove.

    Any layers that are added to the Affected Objects list swirl around the layer to which the Vortex behavior is applied.

To affect only Related Objects
  1. In the Layers tab, move the object with the applied Vortex behavior into the group that contains the objects you want to affect. In this case, drag the “center star” object from the Center group into the Stars group. When the drop menu appears, choose Move Shape to Group.

    Note: For more information about the drop menu, see Converting Between Shapes and Masks.

    Figure. Layers tab showing "center star" layer being added to the "Stars" group.
  2. In the HUD or Inspector, set the Vortex Affect parameter to Related Objects.

    The objects in the group circle around the target object.

    Note: Other Simulation behaviors that also use the Affect parameter include Attractor, Repel, and Drift Attractor.

Example 4: Creating a Clock Animation

In this example, two Parameter behaviors are used to create an animated clock. By arranging the layers and their anchor points properly, each part’s motion can be created quickly and easily using the Rate and Oscillate behaviors.

Note: The source files for this example are not included in the Sample Media folder.

To create a clock animation
  1. Place the graphics layers constituting the hands, face, and pendulum into the Canvas, arranging them to create the clock.

    The hands are on top, the face in the middle, and the pendulum should be in the back.

    Figure. Canvas window showing elements to make up a clock graphic.

    By default, the anchor point is located at the center of each object. Prior to adding behaviors to animate these layers, you need to move the anchor points so that the layers move the way they’re supposed to. In this example, the hands should spin about the center of the clock face, not the center of the hand itself, and the pendulum should swing from its top.

  2. Choose the Adjust Anchor Point tool and move the anchor points of both hand layers and the pendulum layer to the center of the clock face.

    Figure. Canvas window showing anchor point of clock hands moved to center of clock.

    Now that the composition is set up to be animated, the only remaining thing to do is to assign behaviors to each of the layers.

  3. Select the minute hand layer, open the Properties tab in the Inspector, Control-click the Rotation parameter, then choose Rate from the shortcut menu.

    The Rate Parameter behavior is applied to the Rotation parameter.

    Figure. Inspector showing Rate behavior being applied to Rotation parameter using shortcut menu.
  4. In the Behaviors tab, set the Rate parameter to –49.

    This rotates the minute hand clockwise at a continuous rate.

    Figure. Behaviors tab showing settings for Rate behavior.
  5. Select the hour hand layer, Control-click its Rotation parameter in the Properties tab, then choose Rate from the shortcut menu.

  6. In the Behaviors tab, set the Rate parameter to –4.

    Figure. Behaviors tab showing Rate set to -4.

    When you play the project at this point, you can see that the hour hand and minute hand rotate clockwise at rates replicating the relative movement of real clock hands.

    Figure. Canvas window showing rotating clock hands.

    Tip: To make the hands of the clock appear to “tick,” you can apply the Quantize Parameter behavior to the Rotation parameter of the hands and adjust the Step Size to accommodate your animation.

    Now it’s time to make the pendulum swing. You should have already adjusted its anchor point to be at the top. This way, the bottom pendulum layer will swing properly.

  7. Select the pendulum layer, Control-click the Rotation parameter in the Behaviors tab, then choose Oscillate from the shortcut menu.

  8. In the Behaviors tab, set the Oscillate behavior’s amplitude to 20.

    The pendulum layer doesn’t swing so widely.

  9. Increase the speed to 50.

    This keeps with the overall fast-forward motion of the clock. You’re done!

    Figure. Behaviors tab and Canvas window showing effect of speed parameter on pendulum swings.