Adding a New Buff
Add Buffs to Your Attack Skills
First, you need to find your skill prefab. You'll see that two new properties have been added to the skill script: the "Add Buff Event" where you can select a only event, and the second one where you can add your own or preset three buffs.
Assets/RGame/RoguelikeKit/Prefabs/Skill/BothSideSkill.prefab
Adding a New Buff
This guide walks you through creating and configuring a new buff in the RGame RoguelikeKit, using BurnBuff as an example.
1. Inspect the Existing Buff Asset
In Unity, navigate to:
Assets/RGame/RoguelikeKit/ScriptableObjects/DataSO/Buff/BurnBuff.asset
Select BurnBuff.asset to view its properties in the Inspector. You will see four key fields:
Duration: Total lifespan of the buff (in seconds).
TickInterval: How often TickEffect() is called. For BurnBuff, this is set to 1s (one damage tick per second).
OnRemove: choose a unique event.
Damage: Amount of damage dealt each tick.

The remaining two built‑in buff types (e.g. FreezeBuff, SlowBuff) use the same properties—just examine their asset files and you’ll see how Duration, Interval, and effect parameters differ.
2. Create a New Buff Script
Right‑click in your project window and choose Create → RGame → RoguelikeKit → Buff → BaseBuff (or duplicate BurnBuff and rename).
Name your new script: MyCustomBuff.cs.
3. Implement Core Methods
Each buff requires three overrides in your BaseBuff subclass:
Activate(): Called when the buff is applied.
TickEffect(): Called every TickInterval seconds while active.
DeActivate(): Called when the buff expires or is removed.
Below is the full BurnBuff implementation for reference:
using UnityEngine;
namespace RGame.RoguelikeKit
{
[CreateAssetMenu(menuName = "RGame/RoguelikeKit/Buff/BurnBuff")]
public class BurnBuff : BaseBuff
{
public int Damage;
private EnemyHit _ownerHit;
public override void Activate()
{
BuffName = "BurnBuff";
// Visual: tint sprite red
var mat = Owner.MySpriteRenderer.material;
mat.SetColor("_FlameRedBlend", Color.red);
// Cleanup on death
Owner.OnDeath += OnOwnerDestroy;
// Cache damage component
_ownerHit = Owner.GetComponentInChildren<EnemyHit>();
}
public override void DeActivate()
{
// Reset visual
var mat = Owner.MySpriteRenderer.material;
mat.SetColor("_FlameRedBlend", Color.white);
// Remove death listener
Owner.OnDeath -= OnOwnerDestroy;
}
public override void TickEffect()
{
base.TickEffect();
_ownerHit.Hit(Damage);
}
private void OnOwnerDestroy(Enemy owner)
{
// Raise event to clear buffs
RemoveAllBuff.RaiseEvent(this);
}
}
}
4. Configure Your New Buff Asset
In the Inspector, set Duration, TickInterval, and any custom parameters (e.g., damage, slow percentage).
Wire up OnRemoveAllBuff to the appropriate event channel.
5. (Optional) Use Your AI Assistant
If you prefer, ask your AI assistant to scaffold a new buff class using this pattern:
Tell me to create a {BuffName} that {effect description} every {interval}s for {duration}s.
Your assistant can generate the C# boilerplate and even set up properties—no coding worries required.
You don't need to worry about the AI being unable to create the effect you want. As long as it's not particularly complex, the AI can handle it.
You’re all set! With this pattern, you can rapidly add new buff types—just follow the Activate(), TickEffect(), and DeActivate() lifecycle, then configure the asset parameters in the Inspector.
Last updated