As of late 2021, we are in the process of updating Stencylpedia and fixing up outdated & broken content. Thanks for your patience!

87,551

Views

Beginner

Level

14

Comments

Customizing Actors

by Jon (Updated on 2015-10-21)


Contents

  • Introduction
  • What is Actor Customization?
  • You can refer to specific Actors/Regions inside a Scene
  • Example: Pressing Switches

Introduction

Sometimes, you want an actor to act a little bit differently from the norm. Suppose that we’ve created a basic enemy for a Mario-like game, like a Goomba.

Now, we want to make a Hopping Goomba - one that jumps.

You could do this by creating a brand new Actor Type, copying everything about the regular Goomba, and adding a Jump behavior. But a few too many times and you end up with this...

Is there a better way to go about this? There is. It’s called Actor Customization.

What is Actor Customization?

Actor Customization is a feature that lets you tweak a specific instance of an Actor to behave differently.

How To: Customize an Actor

  1. To customize an Actor, left-click on the actor. Then click the Inspector Pane tab on the right hand side of the screen.

    Inspector Tab

  2. From there, check "Customize" box.

    Customize Check Box

From this point, you can start customizing the actor in a few ways.

  • You can add Behaviors.
  • You can remove Behaviors.
  • You can customize the values of the behaviors it has.

How To: Add Behaviors

Click the + button in the Inspector to add a Behavior.

Add Behavior Button

Doing so will bring up a dialog that lets you choose a Behavior to add, for example one that lets our Actor jump and run.

Add Jump and Run Behavior

How To: Remove Behaviors

You can also remove a Behavior (for this Actor instance) from the Inspector by clicking the X button.

Delete Behavior

How To: Customize Behaviors

Suppose that we want a particular Actor to walk really quickly. We could increase the “Minimum Speed” field for the "Wander" Behavior that's already attached to this actor.

Walking Speed

You can refer to specific Actors and Regions within a scene.

Recall that an Actor’s behaviors can’t directly refer to specific objects within a scene. This is why, when you attach a Behavior to an Actor, and that behavior has an Actor attribute, you see this.

Because an Actor’s behaviors are generic, they have no connections to specific scenes. In other words, there's no context for referring to things in specific scenes.

Is there a way to enter values into these fields for Actors? There is! Once you customize an actor, those Actor attribute fields can now let you pick out specific Actors and Regions within a scene.

I’ll explain how to do this through a common example: pressing switches.

Example: Pressing Switches

Suppose that you're playing an adventure game like Zelda. You're inside a dungeon, and you come across a room with several switches. Stepping on a switch causes a particular door to open.

How can we use Actor Customization to make this work?

In a gist, we'll create a “Switch” behavior that, given a “Door” actor, will tell that Door actor to open up when our Hero steps (collides) on the switch. (The switch should also visually change to a pressed-down state)

Through Actor Customization, we can customize each instance of a switch, so each one will open up a particular door when pressed.

Walkthrough

Note: As always, these explanations are for learning purposes. You’ll need to tweak the approach to fit your game's needs.

  1. Download the Customizing Actors project. Import it using File > Import Game... and open it up.

  2. Open the main scene.

  3. Left-click the left switch (there are two switches total). Then, click the Inspector tab on the right. Click the Customize check box in the Inspector.

  4. Notice that you now have full control over what behaviors are attached to this particular switch.

    Inspector Switch Behavior

  5. Click on Door Actor... in the Inspector - this will prompt you to choose the actor that this switch is connected to. Choose the left door.

    Choose Door

  6. Test the game. Step on the left switch. The left door will open.

  7. Finally, configure the right switch to open the right door. Test again.

That's it!

Recap

You’ve customized the switches so that when the left/right switch is pressed, the left/right door opens.

How does this work? Let's take a peek into the "guts" of this sytem. Open up the Switch Behavior behavior.

The key piece is the Actor attribute called Door Actor. When you customized the Switch actor (via the Inspector pane), the "Door Actor" attribute let you pick a SPECIFIC door within the scene.

If you understand that connection, you now fully understand how Actor Customization works.

Summary

  • Use Actor Customization to tweak the behavior of actors rather than creating brand new ones.
  • Actor Customization lets you modify the attached set of behaviors and modify each behavior’s values, for a particular instance of an Actor within a scene.
  • You can refer to specific Actors and Regions within a scene through Actor Customization.
Print Article Edit Article How to Edit an Article
Disclaimer: Use comments to provide feedback and point out issues with the article (typo, wrong info, etc.). If you're seeking help for your game, please ask a question on the forums. Thanks!

14 Comments

shuaib287
what the heck . my character still doesnt behave probably
0 7 years, 4 months ago
ScottiBanter
Hi, I know that this's an old thread but I was wondering how I might apply this technique to not only change the animation, but change the actor, I'm guessing it's possible but I just don't know how. I'd also like to know how to upon collision with another actor change the player's behaviours (or whatever actor you want to change the behaviours of). Thanks for the help.
1 9 years, 1 week ago
Jon
Article has been updated for clarity.

The pressing switches project has been rebuilt and verified to work in Stencyl 3.4.0. (Do not use Stencyl 3.3 or earlier)

0 9 years, 2 months ago
gubba
Using 3.1.0 b7305 .
Got the example file going by adding actor-actor events under the 'main' scene.
That gave me a graphic to click the specific actor and brings up the 'when actor hits actor code wrapper.
yippee

0 10 years, 6 months ago
Jon
Our apologies for the broken materials. Stencylpedia is has become quite a challenge maintain, and this is why we don't supply more sample games - because a broken sample game is worse than none at all. We'll figure out a better system to handle this in the future.
0 10 years, 11 months ago
CatCannons
Does anyone know how to make it so that an actor will fire projectiles towards the player as of them entering a certain region?
0 11 years, 3 months ago
HadBabits
Why is it these tutorials always contain incomplete assets? :(
0 11 years, 3 months ago
jammer2407
i cant figure out how to delete an actor from a scene.
0 11 years, 11 months ago
MarkRosewood
It is possible to get this to work. It seems like it's just the 'Switch Behaviour' that's missing.

Steps to create it are:

Create an Actor Behaviour called 'Switch Behaviour'
Add an Attribute to it of type Actor called 'Door Actor'
Add an Event Collisions->Actor of Type
Add the red (above) 'trigger event ' block (from Behaviour->Triggers palette)
Type text 'open' and select attribute 'Door Actor' as above (except it's in red not blue)
Add the blue (above) 'switch animation to' block (from Actor->Draw palette)
Type text 'off' instead of the blue 'Pressed State' above
Save and go over to the Switch Actor and add the Switch Behaviour

Now you should be able to go to the Scene and do the customising as above and get the correct result when you run it.

1 12 years, 2 months ago
wizopizo
Please note that all of this is invalid now and doesn't work sadly.
0 12 years, 3 months ago

Sign In to Comment