Whimsy

Making a following critter

Followers and random critters in your project can liven up the game and create characters your players will think more about — maybe as a protector, or as a buddy. Plus, such characters can also be useful helpers, or tell stories about your world!

In this tutorial you will learn how to make a simple Actor that will follow your Hero around.

Basic implementation

For the first example, let's make a non-interactive character that will simply move your Hero around:

Playable demo!

Firstly, create and draw an Actor that will follow your Hero. You can make it animated, or you can make it static.

Then unmark its "Impassable" state: as this Actor will actively follow the Hero around, there can be circumstances where this Actor would block a narrow passage. To prevent that, we mark it as passable so a player can always walk through this Actor if needed.

You can also change its movement behavior to flip horizontally, or, if you're making a top-down game, make it rotate. This will ensure the critter will look in the direction it moved last.

Then open the Scenario tab at the top, and add an event "When hero moves". Attach a block "Move this actor", and set its direction to "Towards the hero". Also make sure that the checkbox "Avoid touching the hero" is ticked.

You're almost done — now place your new Actor onto a stage and test it out!

Note

Actors in Whimsy can't move across Stages, and if you need to simulate a critter that follows your hero through them, you will need to place this Actor's instance in each Stage you want the critter to be in.

Creating an advanced, interactive follower

Sometimes you will want a character your Hero can interact with, and it would be rude if we walked over them, too. In such cases, people oftentimes add dialog options to let players chat with their followers, and also to provide an option to swap places. With an additional simple tweak, we can also make sure the follower always gets placed near the Hero when player moves across Stages, even with several entrances leading to the same stage:

Playable demo! Try walking into tight corridors and swapping places with Hero's follower.

For this variant, start by following all the previous steps but make the Actor impassable.

Dialogue tree and swapping places

Add a new event called "When touched by a hero", and connect an "Ask for a choice" block to it. This block will show dialogue options with a prompt above them, and that's where we will place an option to swap places with the character, and where we can later add various story-related choices. Add several "outputs" to this blocks, and name one as "Swap places", and also add another one to do nothing. ("Just checking in" optin in the demo above.) The latter option will have no blocks connected to it, while the "Swap places" option will have few blocks to manipulate Actor's and Hero's positions.

We need to swap places, and while we have blocks that can retrieve the location of the Hero and of Actors, we need to remember the position of one of them before we move another. We will use variables for that. Go to your project's Settings tab and create two numeric variables, called Temp. X and Temp. Y. ("Temp." means "temporary" here.) Then go back to your follower's Scenario and continue the script by adding two "Write this variable" blocks, both connected to a "Get my location" block. Make sure you properly store X and Y variables and don't mix them up.

Then, after the second "Write variable", add a block called "Jump to location", and connect its X and Y inputs to another block called "Get Hero's location". This will move the Actor to Hero's location, and what's left after that is moving the Hero to old Actor's position we just remembered with variables. To do that, add a block called "Move Hero to (programmatic)". This block is usually used to move a Hero across Stages with specific coordinates you compute in some way, and it can also be used to move the Hero inside the current Stage. It's similar to exits!

We do not need to change stages, so we connect the "Stage ID" input to another new new block "Current Stage ID". Finally, fill in the X and Y inputs with two "Read variable" blocks that will retrieve the values of Temp. X and Temp. Y variables.

Always placing the Actor near the Hero

As we will essentially place individual duplicates of our follower Actor to simulate them moving across Stages with the Hero, we will most likely need to also position these Actor instances near the Hero when a new Stage opens — this is especially important for Stages to which a player can come from multiple entrances.

We can use the same block "Get Hero's location" to teleport to their tile when a Stage starts for that! And to move the Actor away from the Hero (so it doesn't stay on top of the Hero's tile), add a "Move this Actor" command, and set its direction to "Away from the hero with evasion".

And that's it! Feel free to expand the "Ask for a choice" with options relevant to your plot, and don't forget to add this Actor to all the Stages it must be present in.

Complete scenario