WaitForSecondsAction

Concrete Action that pauses execution for a configurable number of seconds using the Yield async system. This is the canonical example of an async, cancellable action.

Definition

Namespace: Paragon.Core.ActionSystem Assembly: Paragon.dll

public class WaitForSecondsAction : Action

Inheritance: Action → WaitForSecondsAction

Remarks

WaitForSecondsAction demonstrates the recommended pattern for time-based async actions. It uses Yield.WaitForSeconds() from Paragon.Core.Async, which integrates with the CancellableTask system — meaning this action is automatically cancellable at the yield point without any manual cancellation token handling.

The duration field is marked with [Variable], allowing it to be set via the Inspector, through the variable API (SetVariable), or bound from an ActionVariable.

Quick Lookup

Goal
How

Wait 2 seconds

Set duration to 2f, call Execute()

Set duration via API

action.SetVariable("duration", 2f)

Cancel mid-wait

action.Cancel()

Await completion

await action.ExecuteAsync()

Methods

OnExecute

Awaits the configured duration using the Yield system. Cancellation is automatically handled at the yield point.

Behavior: Calls await Yield.WaitForSeconds(duration), which suspends execution for duration seconds (in real time). If Cancel() is called during the wait, the CancellableTask terminates execution at the yield point.

Properties (Variable Fields)

Field
Type
Access
Description

duration

float

private / [Variable]

Time in seconds to wait before completing

Common Pitfalls

circle-exclamation
circle-info

Duration is applied before execution Because duration is a [Variable] field, its value is synced from the variable system via ApplyFieldVariables() before OnExecute() runs. Setting the variable via SetVariable("duration", value) before calling Execute() will be reflected correctly.

Examples

Basic Usage

In an ActionSequence

Cancellation

See Also

Last updated