<aside> <img src="/icons/reorder_gray.svg" alt="/icons/reorder_gray.svg" width="40px" />
Navigation
</aside>
<aside> 💡 A new booster needs a script, an asset, an entry in the Booster Database and a pickup prefab.
</aside>
Create the booster script. Inherit from TimedBooster for an effect with a duration or from InstantBooster for a one-shot effect. Implement OnActivated. A timed booster also implements OnDeactivated to revert the effect.
using UnityEngine;
namespace Watermelon
{
[CreateAssetMenu(fileName = "Magnet Booster", menuName = "Watermelon/Boosters/Magnet")]
public class MagnetBooster : TimedBooster
{
[SerializeField] private float range = 6f;
public override void OnActivated(PlayerController character)
{
// Start the effect
}
public override void OnDeactivated(PlayerController character)
{
// Revert the effect
}
}
}
Create the asset. Open Create → Watermelon → Boosters → Magnet and save it in Assets/Project Files/Data/Boosters.
Fill the fields. Set a unique Id, the Icon, the Frame Material, the Drop Weight, the Activation Sound and the Duration.
Register the booster. Open Assets/Project Files/Data/Booster Database.asset and add the asset to the Boosters array.
Create the pickup prefab. Duplicate Booster Pickup in Prefabs/World Objects, assign the Booster and the cube frame material.
Place it. Add the pickup, a Booster Box Random entry or a Booster Spawner entry to a level scene. Save the scene.
BoosterDatabase.GetBoosterById logs a warning for a missing id.[System.NonSerialized] fields and release them in Unload().Unload() is called when the Game scene unloads. ScriptableObjects outlive scenes, so a pool or a container created by a booster must be released there.PlayerController public API when the character must change. Booster assets only call the API.PlayerController.OnEffectActivated(effectId) receives the Id of the booster. Override it in a PlayerController subclass, or extend BoosterVisualBehavior, to add a visual that is specific to the booster.
Use VehicleSwapBooster. Create a VehicleData asset for the vehicle and assign it to the Vehicle field. See Vehicle Data & Movement Behaviors.
character.SwapVehicle(vehicle);
character.RevertVehicle();
ActiveBoosterHUD shows every timed booster in a free slot of the list. The number of slots in the UI Game prefab limits the number of active timed boosters that are displayed. Add slots to the list for more.