About unity-strategy-pattern
A Unity skill for replacing conditional behavior with interchangeable Strategy objects. It supports ability and spell systems whose behaviors can be swapped at runtime and extended without changing PlayerController.
Key features
- 01Encapsulated behavior strategies
- 02Runtime strategy swapping
- 03Add behaviors without changing PlayerController
- 04ScriptableObject and class-based strategies
- 05Spell and ability system guidance
Use cases
- 01Replacing switch-based spell logic
- 02Changing an entity's behavior at runtime
- 03Adding abilities without modifying PlayerController
Install
Copy the command and run it in a terminal.
$
npx skills add https:/ / github.com/ muharremtozan/ unity-agent-skills --skill unity-strategy-patternAfter installing, type/unity-strategy-patternin Claude Code to confirm it loaded.
Bundled files
References and scripts installed along with SKILL.md.
assets/code/OrbitalSpellStrategy.cs.txtShieldSpellStrategy.cs.txtSpellStrategy.cs.txtreferences/guide.mdDetails
From the project READMEUnity Strategy Pattern
This skill implements the Strategy Behavioral Pattern to replace conditional logic (switches/ifs) with interchangeable algorithm objects.
Core Features
- Encapsulated Logic: Each behavior (Fireball, Shield, Orbital) lives in its own
ScriptableObjector class. - Hot-Swapping: Change an entity's behavior at runtime by swapping the strategy asset.
- Open/Closed Compliance: Add new spells/behaviors without modifying the
PlayerController.
Core Files (assets/code/)
SpellStrategy.cs.txt: Base abstract ScriptableObject (The Interface).ShieldSpellStrategy.cs.txt: Simple instantiation strategy.OrbitalSpellStrategy.cs.txt: Complex math/logic strategy (Pro Path).
Usage Guide
See GUIDE.md to learn how to create flexible Ability/Spell systems using Strategies.
Comments
Markdown supported