Home


Unlock Ability

In certain games, the player must find and unlock new abilities in order to progress through the game. These abilities are often obtained by completing certain tasks or finding hidden items.

This tutorial will show you how to set up the foundation for unlocking abilities. It is important that once an ability is unlocked, it remains unlocked throughout the lifespan of the game. The WorldBool component is crucial for this to work.

To get started, add the WorldBool component to your player controller.

The WorldBool component is used for saving. To use it correctly, enable the Save option, give it a unique Name ID, and initialize its Value to false. You can also clear any saved data by pressing the trash icon in the Save section.

We can use the fact that each ability can be paused by calling the Pause method on it. For convenience, you can press the pause icon (which will turn red) to pause an ability.

To apply this to the Jump Ability, for example, drag and drop the player object into each On Load event and select the Pause method. This can be applied to any ability, as well as the FireArm and Melee classes (with Flare 1.7.2).

When the game starts, the On Load Condition True event will be called if the Value is True, and this will set the Pause method to False, which will unlock the ability. Otherwise, the On Load Condition False event will be called and the Pause method will be set to True, which will pause the ability.

Important: Since each ability must be unlocked or locked in every scene, this means this setup must exist in each scene, and each WorldBool must have the exact same settings. Typically, this should be part of the player prefab.


This example shows how to unlock the double jump ability. Since the double jump is part of the Jump Ability, it can't use the Pause method. Instead, we can set the number of air jumps directly by calling the SetAirJump method.

Tip: If you have a lot of abilities to unlock, you can place multiple WorldBool components on a separate game object to keep them organized.

The only thing left to do is set the WorldBool value to True. The specific scenario in which this happens will depend on your game. It could be triggered by AI or by picking up an Item. The important part is to call the SetTrue method on the WorldBool. It's also important to call the ability you want to unlock at the same time, or else the ability won't activate until the scene resets.

In the example above, the player has the jump ability already enabled and I use an AIFSM. When the player enters the territory, it will unlock the player's double jump ability. If you exit and enter play mode again, you'll be able to double jump immediately. See the image below to see how I set up the AIFSM. If you are new to AIFSM, refer to the documentation or YouTube tutorials for more information.