Get up and running with the Modifier System and Character Templates in minutes.
Prerequisites
Before You Start: You need a generated attribute system from the Base tier. If you haven't created one yet, use Window > Simple Attribute Forge > Attribute Wizard first.
Wait for Unity to compile (check console for progress)
Assets are automatically created after compilation
Generated! You now have StrengthPotionAsset.cs, StrengthPotionComponent.cs, and StrengthPotionHelper.cs, plus a StrengthPotion.asset file ready to use.
Using Your Modifier
Option 1: Using the Helper Class (Code)
using MyGame.Modifiers;
public class ItemUseHandler : MonoBehaviour
{
public void UseStrengthPotion(GameObject target)
{
// Apply the modifier
StrengthPotionHelper.ApplyStrengthPotion(target);
}
public void DispelStrengthPotion(GameObject target)
{
// Remove the modifier
StrengthPotionHelper.RemoveStrengthPotion(target);
}
}
Option 2: Using the Component (Inspector)
Create a new GameObject (or use existing item)
Add the StrengthPotionComponent script
Configure in Inspector:
Apply On Start: Check if you want it to apply immediately
Remove On Destroy: Check to auto-remove when destroyed
Target Override: Leave empty to target self, or assign a specific target
Call ApplyStrengthPotion() from your code or use context menu
Option 3: Using the Asset (ScriptableObject)
public class ItemSystem : MonoBehaviour
{
[SerializeField] private StrengthPotionAsset strengthPotionAsset;
public void UseItem(GameObject target)
{
// Apply using the asset's method
strengthPotionAsset.ApplyStrengthPotion(target);
}
}
Part 2: Create a Conditional Modifier
Now let's create "Berserker Rage" - a buff that only activates when Health is below 25%.
1Add New Modifier in Wizard
Name: Berserker Rage
Description: Increased damage when near death
Tag: passive
Duration: 0 (permanent while conditions met)
2Add Conditional Modification
Click "Add Modification"
Target Attribute: Strength (or Damage if you have it)
Type: Percentage
Value: 50 (50% increase)
Enable Conditions: Check this box
3Add Attribute Condition
Click "Add Condition"
Attribute: Health
Comparison: LessThanPercent
Threshold: 25
Logic Operator: And
4Generate and Test
Generate the code as before
The modifier will only apply its effect when Health < 25%
Use BerserkerRageHelper.CanApplyBerserkerRage(target) to check conditions
Condition Check in Generated Code
// Generated helper includes condition checking
public static bool CanApplyBerserkerRage(GameObject target)
{
var container = target.GetComponent();
if (container == null) return false;
var healthAttr = GetAttributeHybrid(container, "Health");
if (healthAttr == null) return false;
// Check: Health < 25%
if (!(healthAttr.GetPercentage() < 25f)) return false;
return true;
}
Part 3: Create a Character Template
Let's create two character classes: Warrior and Mage with different starting stats.
1Open the Character Template Wizard
Go to Window > Simple Attribute Forge > Character Template Wizard
2Step 1: Select Attribute Data
Select the same AttributeData source you used for modifiers.
3Step 2: Define Character Classes Add Warrior Class:
Click "Add Class"
Class Name: Warrior
Description: Melee fighter with high strength and endurance
Set attribute overrides:
Strength: 15 (check "Use Override")
Endurance: 12 (check "Use Override")
Vigor: 14 (check "Use Override")
Add Mage Class:
Click "Add Class"
Class Name: Mage
Description: Spellcaster with high intelligence and attunement
Set attribute overrides:
Intelligence: 16 (check "Use Override")
Attunement: 14 (check "Use Override")
Faith: 10 (check "Use Override")
4Step 3: Configure Generation Settings
System Name: Character Templates
Namespace: MyGame
Output Path: Assets/Generated/CharacterTemplates/
Check "Generate Manager Component"
Check "Generate Helper Class"
Check "Generate Enum Definitions"
5Step 4: Generate Code
Click "Generate" and wait for compilation.
Generated! You now have [SystemName]CharacterTemplateEnum.cs, [SystemName]CharacterTemplateManager.cs, [SystemName]CharacterTemplatesHelper.cs, plus .asset files for Warrior and Mage. Replace [SystemName] with your configured system name.
Using Character Templates
Apply Template at Character Creation
using UnityEngine;
using SimpleAttributeForge.CharacterTemplate;
// Use your generated namespace, e.g.:
// using Soulslike.CharacterTemplates;
// using MyGame.CharacterTemplates;
public class CharacterCreation : MonoBehaviour
{
public void CreateWarrior(GameObject character)
{
// Find template by name and apply to GameObject
var template = CharacterTemplatesHelper.FindTemplateByName("Warrior");
CharacterTemplatesHelper.ApplyTemplateToGameObject(character, template);
}
public void CreateMage(GameObject character)
{
var template = CharacterTemplatesHelper.FindTemplateByName("Mage");
CharacterTemplatesHelper.ApplyTemplateToGameObject(character, template);
}
}
Get Template Data
// Get all available templates (static helper method)
var allTemplates = CharacterTemplatesHelper.GetAllTemplates();
foreach (var template in allTemplates)
{
Debug.Log($"Available class: {template.templateName}");
Debug.Log($"Description: {template.description}");
}
// Find a specific template by name
var warriorTemplate = CharacterTemplatesHelper.FindTemplateByName("Warrior");
if (warriorTemplate != null)
{
Debug.Log($"Found: {warriorTemplate.templateName}");
}
// Get attribute value from a template
float strength = CharacterTemplatesHelper.GetAttributeValue(warriorTemplate, "Strength");
Note: The Helper class is static and can be called from anywhere. The Manager class is an optional MonoBehaviour component you can attach to GameObjects for Inspector-based template management.
Complete Integration Example
Here's how all systems work together:
using UnityEngine;
using SimpleAttributeForge;
using SimpleAttributeForge.CharacterTemplate;
using SimpleForgeFramework;
// Use your generated namespaces, e.g.:
// using Soulslike.CharacterTemplates;
// using Soulslike.Modifiers;
public class RPGCharacter : MonoBehaviour
{
[SerializeField] private string characterClassName = "Warrior";
[SerializeField] private SimpleCharacterTemplateData startingTemplate;
private ISimpleAttributeDataSource attributes;
void Start()
{
attributes = GetComponent<ISimpleAttributeDataSource>();
// Option 1: Apply template from serialized reference
if (startingTemplate != null)
{
CharacterTemplatesHelper.ApplyTemplateToGameObject(gameObject, startingTemplate);
}
// Option 2: Apply template by name
else
{
var template = CharacterTemplatesHelper.FindTemplateByName(characterClassName);
if (template != null)
{
CharacterTemplatesHelper.ApplyTemplateToGameObject(gameObject, template);
}
}
// Apply permanent passive modifier
BerserkerRageHelper.ApplyBerserkerRage(gameObject);
}
public void UseStrengthPotion()
{
// Apply temporary buff
StrengthPotionHelper.ApplyStrengthPotion(gameObject);
}
public void TakeDamage(float damage)
{
var health = attributes.GetRuntimeAttribute("Health");
health.currentValue -= damage;
// Berserker Rage conditions are evaluated when the modifier was applied
}
public void CheckActiveBuffs()
{
// Query active modifiers
var activeModifiers = SimpleModifierTracker.GetActiveModifiers(attributes);
foreach (var modifier in activeModifiers)
{
Debug.Log($"Active: {modifier.name} ({modifier.tag})");
}
// Check for specific modifier
if (SimpleModifierTracker.HasModifierByName(attributes, "Strength Potion"))
{
Debug.Log("Strength potion is active!");
}
}
}