Building the LEGO Skeleton Behavior

As the LEGO Skeleton actors should behave like mindless zombies, we're going to have the Skeleton actor mindlessly follow the Main actor when the Skeleton enters the Main viewport.

Adding Gravity and Jump Behaviors Using Shortcuts

Just like we did with the Security actor, let's reuse the built-in "run and jump by pressing keys (side view)" shortcut to create the gravity and jumping behaviors automatically. Remember to delete the RunLeft and RunRight behaviors like we did before.

Updating the Jump Behavior

Like we did previously, we will update the Jump behavior event to fire during a random time interval between 2 and 8 seconds (see Figure 2-43).

Creating a Behavior to Follow the Main Actor

Next we'll create a new motion behavior that will make the Skeleton actors mindlessly follow the Main actor. To do this, create a new motion behavior for the Skeleton actor. Set the event for the motion behavior to be when the Main actor enters the viewport with the Skeleton actor, as shown in Figure 2-54.

Firing an event when the Main actor enters the Viewport

Figure 2-54. Firing an event when the Main actor enters the Viewport

Now that the Skeleton's motion will begin when the Main actor enters the scene, next let's configure what the particular motion will be when the event is fired. To do this, click the "Motion1" behavior's Motion button and set the "Relative to" value to the Main actor. When you do this, you'll notice ...

Get Coding4Fun now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.