• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL

Lesson 4. Working with Behaviors > Working with the Repel From Behavior

Working with the Repel From Behavior

The last Simulations behavior that you'll experiment with in this lesson is the Repel From behavior. Simulations behaviors include Attract and Repel behaviors that either move objects toward each other or cause them to move away from each other. The Repel From behavior is applied to an object or objects; then you specify what the objects are repelled from.

Let's open the project 4-7 Repel From to see this Simulations behavior in action.

Choose File > Open and select 4-7 Repel From in the Lesson_04 folder.

Play the project in the Canvas to see the effect.

As the AquaBall bounces around the frame, the small white circles move away from the AquaBall.


This project was really easy to create. The AquaBall is just an object with Throw and Edge Collision behaviors. The small circles are actually bullet points (Option-8) that I created as one piece of text using the Text tool.

Now it's your turn.

Resetting Parameters in the Inspector

The secret to making the Repel From behavior work is experimenting with the parameters until you get the desired result. Let's re-create the effect we just saw by setting the Repel From parameters from scratch.

First, let's reset the current parameters in the Inspector. To reset parameters, you click the Reset button (X) in the Inspector.

To open the Inspector from the Dashboard, Motion gives you a really handy shortcut. All you need to do is click the Inspector button, which looks like a white circle with an i in the center.

In the upper-right corner of the Dashboard, click the Inspector button.

The Inspector tab opens in the Utility window with the Behaviors tab showing.

Click the Reset button.

The parameters are reset to the default values.

Play the project in the Canvas.

The AquaBall bounces around behind the white circles.

Setting Repel From Parameters in the Inspector

To make the Repel From behavior work, you need to designate the object that you want other objects to be repelled from.

All you need to do to designate an object is to drag the object from the Layers tab to the Object well. The Object well is the empty square next to the Object parameter.

Press Cmd-4 to open the Layers tab.

Drag the AquaBall object from the Layers tab to the Object well in the Inspector.

The AquaBall appears inside the Object well.

Watch the project in the Canvas with the default Repel From settings.

The default settings don't make the white circles repel enough to be effective. You need to increase the strength of the repellency.

In the Inspector, drag the Strength slider for the Repel From parameters all the way to the right to change the Strength value to 100.

Watch the project in the Canvas again.

The effect is better, but the repellency still isn't strong enough. So what do you do when you've reached the maximum value on the slider and still need more strength? Easy—just type in the value you want.

Click the Strength value field and type 800; then press Return.

There you have it. You've re-created the Repel From behavior settings.


Parameter values in the Dashboard are fixed, so if you want to exceed the initial parameter values, you need to type a new value in the parameter field in the Inspector.

Experiment with the different Repel From parameters to create your own repellency effect.

When you've finished, save your project in the My Projects folder.

  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint