Expert in non-playable characters (NPCs) with a focus on multiplayer hub dynamics and distinctions from single-player NPCs
On The Sandbox metaverse, NPCs have a wide range of capabilities. This article will delve into the different actions they can perform and discuss strategies for working within the engine’s limitations to achieve optimal NPC behavior.
The Sandbox Game Maker v0.8.10.
VoxEdit (if you want to make the characters yourself).
We will start with two types of NPCs that are primarily designed to populate the environment:
The simplest type of NPC is the statue, which remains stationary with its collider active. It can be animated using the ‘Animated Decoration’ behavior by selecting the desired animation.
Statues can also have dialogue lines. To give them a text bubble, you can add a ‘Speaker’ component with your desired text. It can be activated by a message (usually interact) or by proximity (detecting the Avatar).
Statues can also use the ‘Asker’ behavior. If the statue remains in the Idle01 pose, you can add the ‘Asker’ behavior directly to it.However, if you want the statue to be both an ‘Animated Decoration’ and an ‘Asker’, you will need a separate object. Add the ‘Animated Decoration’ behavior to the character, while the second object serves as the ‘Asker’. This second object should be invisible, have no collision, and be placed inside the NPC’s chest.
Don’t forget that every asset triggered by the Interact message should have an ‘Indicator’ to instruct the player to “press E to interact”.
As the name implies, a ‘Citizen’ is an NPC designed to behave like a civilian. Citizens should have collisions disabled to prevent them from colliding with the player. Because they already have the ‘Citizen’ behavior assigned, they cannot use the ‘Asker’ behavior. Therefore, if you want citizens to convey a message, you should use the ‘Speaker’ component.
It is also advisable for the ‘Speaker’ component to be activated by proximity, typically by detecting the Avatar. This way, citizens can interact with the player when they come close.
These two NPCs are the most basic, but there are also two other types that are equally important, despite requiring more functionality to be implemented perfectly.
The quest objective
Usually, quest objectives are highlighted using the ‘Indicator’ component, which works well but can become messy when having multiple objectives,making navigation less enjoyable.
To address this, a separate object, ideally the same one, is used for the ‘Indicator’ component. This separate object also requires the ‘Plant’ behavior so that it gets destroyed when the player interacts with it. To ensure it gets destroyed while also being an objective, a ‘Toggle Behavior’ component, is added and sets as active when the quest begins.
These assets typically have ‘Asker’ behaviors attached to them while they are set as quest objectives, so “Press E to...” interaction prompt should be active. In such cases, the player can interact with the asset before, during and after the quest. To handle this, it is desirable to use a second separate asset with an ‘Asker’ behavior and a ‘Toggle Behavior’ that ensures it is active both before and after the quest. However, for a more organized setup, it’s cleaner to have a combination of a completely empty asset, two ‘Asker’ assets, and a ‘Plant’ asset. This arrangement provides flexibility, and the empty asset can also serve as an ‘Animated Decoration’ when needed.
The quest giver
Quest givers are somewhat more complex than quest objectives because they rely on their own messages to trigger actions.
Quest givers are typically comprised of an asset representing the giver itself, which can even be an ‘Animated Decoration’. This asset has an ‘Indicator’ component used for instructing the player to “press E to interact” and for indicating that the asset both gives and potentially receives a quest.
There are two methods to give a quest to a player: direct method and the two-steps asker method. The direct method uses an ‘Asker’ set to “Only Once”, but as it may fail at times, the two-steps asker method is often preferred. In this method two ‘Asker’ behaviors are employed to trigger a quest. The first ‘Asker’ triggers the second, and the second, in turn, deactivates the first one (while also triggering the quest). This two-steps approach has proven to be the more reliable and is often the safer choice.
In single-player experiences, NPCs with an enemy role are common. Players typically can’t interact with them, except when engaging in combat. If you want enemies to have dialogue lines, you can add a ‘Speaker’ component with the desired text. It’s recommended to mark it as an “only once” line to avoid overwhelming the screen with repeated dialogue. This way, the dialogue won’t be excessively repetitive during encounters with enemies.
NPCs are a fundamental feature that dynamically populate your environment. These assets bring life to your experience, regardless of the type you choose for your project. Don’t hesitate to mix and match them, create a dynamic flow, and enjoy immersive interactions that engage you with all of them. It’s the diversity and interactivity of NPCs that can truly enhance your project.