Scripting / Instructions
EnemyInstruction
Abstract base for all enemy actions. Extends Instruction directly and adds a reference to the enemy controller executing the action.
Instruction
└── EnemyInstruction ← you are here
├── EnemyInstruction_Move
├── EnemyInstruction_Attack
├── EnemyInstruction_Block
├── EnemyInstruction_Shoot
└── EnemyInstruction_Wait
Additional Field
| Field | Type | Description |
|---|---|---|
controller | EnemyController | Reference to the enemy running this instruction. Injected at runtime by the task system before Tick() is called. Use it to access position, animations, health, and blocking state. |
Inherited Members to Override
| Method | Description |
|---|---|
displayName | Name shown in the enemy's action HUD indicator during execution. |
Execute() | Instant effects — deal damage, change state. Can be empty. |
Tick(ExecutionContext ctx) | Coroutine. Use controller to drive enemy behaviour and ctx.player to read player state. |
Example
using System.Collections; using UnityEngine; namespace LoopAdventure { public class EnemyInstruction_Heal : EnemyInstruction { public override string displayName => "Heal"; public override void Execute() { controller.GetComponent<EnemyHealth>().Heal(2); } protected override IEnumerator Tick(ExecutionContext ctx) { Execute(); controller.PlayAnimation("Heal"); yield return new WaitForSeconds(0.8f); } } }
Full guide
See Create an Enemy Instruction in the Manual for the complete workflow including EnemyAction ScriptableObject setup.