| ThingMaker Documentation Chapter 5) Adding Actions

| Tutorial 7: Collision This Tutorial introduces the Collision Action. The Collision Action is the most versatile of the ThingMaker Actions. You can trigger most of the effects that the other Actions trigger, but most of the other Actions occur as soon as the Thing changes to the State containing the Action. A Collision Action requires that a Thing collide with another Thing. You can specify whether the Collision happens only if a specific Thing is encountered, or whether any Collision will trigger the Action.

Here are the steps you'll perform:

- Open an existing Scene
- Add a Collision Action to a Thing
- Use the Hide Things property to improve the Collision effect

  If you find the material in this Tutorial confusing or difficult to grasp, just take your time, as this is one of the more demanding Tutorials. Sometimes, it helps to break the task down into separate steps and ask yourself what the program is prompting you to do. So for example, when you see parameters like On Collision with and This Thing in the Swap Action Settings, ask yourself in plain English, "on Collision with X, am I supposed to Swap This Thing with Y or what?" (At some points, it might be helpful to take a break and breathe!)

  Getting Started
  1. Run the ThingMaker application.
  If it's not already running, launch the application. If it is open, save your current Scene File.

  2. Open the File Tutorial 7.tms.
  It's contained in:
  drive:\Program Files\Parable\ThingMaker\Tutorial\Tutorial7.tms

  3. Preview the Scene by clicking the Play Button.
  As the Scene plays, the Tree Thing and the Slalom Gate Thing move across the Scene. The Crash animation plays once and stops. If you click on the Ski Thing, you can move it left and right within the Scene, but not by much.

  Adding a Collision Action
  You're going to add a Collision Action to the Ski Thing. You'll see the results when the skier hits the tree.

  1. Open the Settings Palette, select the Ski Thing, and click on the MouseClick Tab.

  2. Drag the Collision Action from the Actions Tool Palette to the MouseClick State of the Ski Thing.

  3. Change the On collision with option to This Thing, and select the Tree Thing from the pop-up list.
  You could actually leave it set to Any Thing which gives you more latitude, but for the moment let's not jump ahead. Set it to This Thing.

  4. Under Perform this action, click the Swap Things option.
  The Collision Action lets you select from most of the other Actions in the Actions Palette by choosing one of the many options in the parameter. Perform this action. If you want to trigger multiple actions with the same Collision, you must add another Collision Action or Actions to the Thing.

  5. Click on the Action Tab.
  When you do, you will see that the parameters for the Swap Action are now available in this Settings Sheet. The Action Tab displays the parameters for the Action selected.

  6. From the With this one pop-up, select the Crash Thing.
  This tells ThingMaker that when the Collision occurs, it should Swap the Location, Visibility, and Layer of the Ski Thing with the Crash Thing.

  7. Test the Scene.
  After pressing the Play Button, click and drag the Ski Thing into the tree. When the two Things collide, the Ski Thing should turn into the Crash Thing animation. Notice that if you move the skier over the slalom gate however, nothing happens. Stop the Scene to reset.

  Adding the Collision to all three States
  1. Play the Scene again, but this time don't click on the Ski Thing. Leave it where it is.
  The Tree Thing will slide over the Ski Thing, and the collision won't be triggered. Why? Because you added the Collision to the MouseClick State alone. If you want the Collision to happen in all three States (and you should), you must add a copy of it to each State of the Thing.

  The Make Same as Default parameter that is available for media elements is not available for Actions. To have the same Action perform in multiple States, you must copy it from one State to another.

  2. Stop the Scene.

  3. Drag the Collision Action from the MouseClick State to the MouseOver Tab.
  ThingMaker will show you that the Action has been added to that State. It will be an exact copy of the Action in the MouseClick State. If you go back to the MouseClick State, you will see that the Collision Action is still there. ThingMaker made a copy - it didn't move the Action.

  4. Drag the Collision Action to the Default Tab.

  5. Test the Scene.
  Now, the Ski Thing should react to hitting the tree, even if you don't click the Mouse.

  Reacting to the other Thing
  You now have a skier that reacts to hitting the tree, but not to the gate. You have three options: the easiest thing to do is to change the Collision attached to the Ski Thing from This Thing to Any Thing. Now the Collision will activate when the Ski Thing and any other Thing in the Scene overlap. Another way to achieve this is to add a second Collision to the Ski Thing. That Action would switch the Ski Thing and the Crash Thing animation when the skier collides with the gate.

  To try this, add a Collision to the Ski Thing. Select the gate as This Thing. Check the Swap Action, and for the parameter With this one, select the crash.

  The third method for creating a Collision is to add the Collision to the Gate. In many cases, which Thing you add the Collision to won't matter. Attaching it to either Thing will work.

  While the Collision Action is only active in the State in which it is applied, the Thing being collided with can be in any State. For some collisions, this is an important difference, and it will have an impact on your decision about which Thing to attach the Collision Action to.

  1. Update the Scene, so that the Ski Thing will collide with the Tree Thing and the Gate Thing.
  Using one of the methods described above, make sure to swap the Crash Thing with the Ski Thing. Don't be afraid to experiment on this one. When you feel you understand what you are doing, continue the Tutorial.

  Fixing the crash animation
  You've probably noticed that the Crash Thing plays when the Scene starts, but that it doesn't when it is swapped with the Ski Thing. That's because the Default animation is set to play only once. More interesting from a visual and design standpoint would be to have the animation play after the crash. Luckily, there is a simple fix. You just hide the crash Thing. How? When you swap the Crash Thing and the Ski Thing, one of the parameters that switches is visibility: ThingMaker hides the Ski Thing and reveals the Crash Thing. When a Thing becomes visible, ThingMaker treats it as though it had been switched to the Default State, and the Thing plays the Default animation.

  Hiding a Thing
  1. Select the Crash Thing in the Scene.

  2. Select Hide Thing from the Edit Menu.
  The Crash Thing is now hidden in the Scene, although the selection rectangle will still be visible.

  3. Test the Scene.
  When the skier crashes into the tree (or gate) the crash animation should play.

  4. Stop the Scene.

  Seeing Hidden Things
  You can see Hidden Things in the Scene during Editing by choosing the Hidden Things option from the View Menu. You can see the Things you've hidden in Edit mode but not in Play mode.

  1. Select Hidden Things from the View Menu.
  The crash Thing should be visible.

  2. Play the Scene.
  When the Scene begins playing, the Crash Thing is hidden and the Scene continues to play as before.

  3. Switch back to Edit mode.

  4. Select the Crash Thing.

  5. Select Hide Thing from the Edit Menu.
  The check mark next to Hide Thing in the Edit Menu goes away. The Thing is no longer hidden. You can choose to hide and to reveal Things with this Menu.

  When to hide Things.
  The Visibility and Hide Things Actions are useful in games, i.e., when a button doesn't become visible until a player clicks another button. They can also be used with the Swap Action if you want to have a Thing play its Default animation after it's been swapped with another Action. You practiced that in this Tutorial. You can also use Hide Things to reduce the clutter in your Scenes. You can also hide or store Things in the background work area of the Scene Window and they won't show themselves in the web page until you attach an Action or a Path to them. In that case, hiding Things that appear in the Scene as a result of a Swap or Location change is not always necessary.

  What next?

  At this point you should have a good understanding of Actions and how to create and manipulate Scenes in ThingMaker.

  In the next three tutorials, you will learn about publishing your Things and the Actions you can use to protect them.

  <--Previous | table of contents | Next -->