上QQ阅读APP看书,第一时间看更新
Adding an Attractor and Attracted To behavior
Goodbye Basic Motion and hello Simulations! While Basic Motion behaviors are some of the most commonly used animation tools, we may also want to simulate real-life movement even further. That's where simulation behaviors come in. Gravity, Wind, Edge Collisions, and more are here to help give your projects that extra magic touch.
How to do it...
- Double-click to open the
03_04_Attractor
project. - This project consists of one large arrow and six small ones. Press the Space bar to play back the project. You'll see that the large arrow moves from the top-left corner of the screen to the bottom-right corner. Stop and move back to the first frame of the project.
- Select the Small Arrows group and press the Command + - shortcut to zoom out on the Canvas to around 20 percent. You should be able to see the bounding box for the group as shown in the following screenshot, but by default, you can't see any of your objects offscreen:
- Navigate to View | Show Full View Area. You should now be able to see those missing arrows as seen in the following screenshot:
- We want these small arrows to follow along with the big one. We're going to apply an Attractor behavior to the big arrow. Select the BIG ARROW group. Go to the gear icon just under the Canvas and choose Attractor under Simulations.
- Play back the project again. Only two arrows seem to move; the arrow inside the BIG ARROW group and the small arrow in front of it. Stop the playback. Select the Attractor behavior and press the F2 key to go the Behaviors tab. Increase the Strength to 100 and Influence to 2000. Now the small arrows follow the big arrow, but the entire animation is springing back and forth.
- If you look closely in the Canvas with the Attractor behavior selected, you can see that the path the group travels along is still the same. Since we've added the behavior to the group and not the YELLOW ARROW layer, it's also influenced by the behavior. In the Layers tab, drag the behavior from the group to the YELLOW ARROW layer.
- Start the playback. Now the small arrows have stopped moving. In the Behaviors tab, change the the value of Affect from Related Objects to All Objects. The yellow arrow attracts the smaller ones as shown in the following screenshot. Adjust the other settings to get a feel for the parameters. When finished, navigate to File | Open and open the
04_04_Attracted_to
project from the exercise folder for this chapter. - Press the Space bar to play the project. This project contains six ants; five small ones and a big one that has been animated using a Motion Path and the Snap Alignment to Motion behavior. We want the small ants to start offscreen and start following the big one at 1 second and 15 frames until the end of the project. Let's add an Attracted To behavior to the small ants to simulate this motion. First, stop the playback and drag the ANT CHILDREN group offscreen to the left. Hold down the Shift key to constrain the movement. Since the group won't start until later, let's trim the layers' in-point. Drag the in-point of the group in the mini-Timeline to 1 second and 15 frames as shown in the following screenshot:
- With the ANT CHILDREN group still selected, go to the gear icon and navigate to Simulations | Attracted To. Press the F7 key to show the HUD.
- You'll see that the Object well in the HUD is set to None. We need to feed it a source. Drag the ANT KING group into the source well, wait for the hooked arrow and release your mouse. Use the following screenshot for reference. Press the Space bar to play back. Navigate to View | Show Full View Area if you can't see the ants offscreen. They're staying still.
- Press the Space bar to stop. Increase the Influence slider to 1500. If you're having trouble adjusting the value in the HUD, go to the Behaviors tab. Play back the project again.
- Increase the Strength to 60, Falloff Rate to 2, Influence to 6000, and Drag to 1. These parameters "push and pull" against each other, controlling how much and little influence the attracted object has on them.
- Now the ANT CHILDREN group still doesn't turn with the motion path. Let's change that by adding Snap to Alignment behaviors to each one of them. Click on the disclosure triangle for the ANT CHILDREN group and select Ant Child 1. Go to the gear icon and select Snap Alignment to Motion from Basic Motion.
- In the HUD, change the axis from Horizontal to Vertical. Select the behavior and press the Command + C shortcut to copy it. Select the remaining ANT CHILDREN and press Command + V to paste the modified behavior as shown in the following screenshot:
Simulation behaviors are very render intensive. It's best practice to stop the playback before trying to tweak them.
Stop the playback when tweaking Simulation behaviors
While it was easy to adjust Basic Motion behaviors and play them back in real time, simulations are render-intensive. It's a good habit to stop the playback and tweak your settings to avoid any small hiccups that Motion could encounter in trying to calculate all that data!
See also
- The Adding Edge Collision and Gravity behaviors to a ball recipe
- The Creating Random Motion using the Randomize behavior recipe
- The Stop, Wriggle, Rate, and Quantize recipe
- The Using the Link behavior recipe