> ## Documentation Index
> Fetch the complete documentation index at: https://docs-unity.molca.id/llms.txt
> Use this file to discover all available pages before exploring further.

# Step (base class)

> Step status, completion rules, StepId, and auxiliaries.

**File:** `Packages/com.molca.core/Runtime/Sequence/Step/Step.cs`\
**Namespace:** `Molca.Sequence`

## When to use

`Step` is the base class for every node in a [SequenceController](/core/sequence-controller) tree. Use it when you need an ordered action that must complete before the next action runs. Create subclasses for custom completion logic (timers, input wait, XR interactions) or use built-in [core step types](/core/core-step-types).

## Status

`StepStatus`: `Inactive`, `Active`, `Completed`.

## Completion

`IsCompleted` is true only when the step is **internally** complete **and** all **child** steps are complete.

## Identity and telemetry

* **`RefId`** / **`RefType`** (`"Step"`) for the [Reference system](/core/reference-system).
* **`StepId`** (int) — correlate with backend scoring when using [Step scoring auxiliary](/vr/scoring/step-scoring-auxiliary).

## Events

`OnStepBegin`, `OnStepEnd` (`UnityEvent`), `OnStatusChanged`, `StartTime` / `EndTime`.

## Auxiliaries

`[SerializeReference] List<StepAuxiliary>` — see Core `Sequence/Auxiliary/` and [VR step auxiliaries](/vr/steps/vr-step-auxiliaries).

In VR training, the **`StepInfo`** auxiliary (and **subclasses** for extra fields) supplies **step titles** used by [Scenario UI](/vr/scenario-ui) **task lists** and modal copy — not just optional scoring/haptics.

## VR subclasses

Training steps in `Assets/_MolcaSDK/_VR/Scripts/Scenario/Steps/` — see the **VR steps** section in navigation.

## Typical custom / VR step (code)

VR steps inherit **`Step`**, wire **`[SerializeField]`** for designers, subscribe in **`OnStepActivated`**, and call **`Complete()`** when the training rule is satisfied (dispatches `Step.Completed` / `Step.FullyCompleted` via [EventDispatcher](/core/event-dispatcher)).

```csharp theme={null}
using Molca.Sequence;
using UnityEngine;

public class ExampleTrainingStep : Step
{
    [SerializeField] private float holdSeconds = 2f;
    private float _elapsed;

    protected override void OnStepActivated()
    {
        base.OnStepActivated();
        _elapsed = 0f;
    }

    public override void UpdateStep()
    {
        base.UpdateStep();
        _elapsed += Time.deltaTime;
        if (_elapsed >= holdSeconds)
            Complete();
    }
}
```

Concrete VR steps (grab, teleport, valve, …) follow this shape with XR-specific fields — see each feature page and the matching `*.cs` under `_MolcaSDK/_VR/Scripts/Scenario/Steps/`.

## API Reference

| Method              | Signature                                    | Description                                                                                                                         |
| ------------------- | -------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------- |
| `OnStepActivated`   | `protected virtual void OnStepActivated()`   | Called when the step becomes active — override to initialize step-specific logic, subscribe to events, or reset state               |
| `OnStepDeactivated` | `protected virtual void OnStepDeactivated()` | Called when the step becomes inactive — override to clean up resources, unsubscribe from events, or save state                      |
| `UpdateStep`        | `public virtual void UpdateStep()`           | Called every frame while the step is active — override to implement per-frame logic like timers or condition checks                 |
| `Complete`          | `protected void Complete()`                  | Mark the step as completed and dispatch `Step.Completed` / `Step.FullyCompleted` events via EventDispatcher to advance the sequence |
| `ForceComplete`     | `public void ForceComplete()`                | Skip `CanComplete()` gate and mark step internally complete. Prefer `Complete()` for normal flow                                    |
| `ResetStep`         | `public void ResetStep()`                    | Reset the step and all its children to their initial, uncompleted state                                                             |
| `OnStepResumed`     | `protected virtual void OnStepResumed()`     | Called when the sequence resumes after pause — override to restore state or restart timers                                          |
| `OnStepCompleted`   | `protected virtual void OnStepCompleted()`   | Called after the step is marked complete — override for post-completion logic before auxiliaries fire                               |

## Related

* [Recipe: Set up a basic sequence](/recipes/setup-basic-sequence) — step-by-step guide to creating a SequenceController with custom steps

## Unity Editor

<Frame caption="Step component on a training object">
  <img src="https://mintcdn.com/ptmolcateknologinusantara/jus_XMBZ8O0U_mpA/images/features/core/step-inspector.png?fit=max&auto=format&n=jus_XMBZ8O0U_mpA&q=85&s=1e7737094eee3c0fc38c89924ae566b4" alt="Step Inspector" width="787" height="483" data-path="images/features/core/step-inspector.png" />
</Frame>
