Skip to content

Component ​

base class in OpalScript

Base type for an OpalScript behavior attached to a scene object.

Properties ​

MemberDescription
SelfThis object as a scene-bound Entity. Compare against null before use.

Methods ​

MemberDescription
GetComponentFind an enabled native or OpalScript component on this entity. Use other.GetComponent<T>() for an Entity reference. Returns null when missing or disabled. References are runtime-only and expose public members.
HasComponentWhether this entity has an enabled component T. Null or expired entities return false.

Lifecycle ​

MemberDescription
StartOnce when this component becomes active during Play.
UpdateEvery gameplay frame. dt is elapsed seconds for this object's time group.
FixedUpdateEvery physics step. dt is the fixed simulation step for this object's time group.
EndOnce when this component is removed or Play stops.
LocalInputEach frame on the locally owned object, before Update.
OnPlayerJoinedWhen a player joins the session. The argument is that player's id.
OnPlayerLeftWhen a player leaves the session. The argument is that player's id.
OnCollisionStartCalled once per solid contact transition on this object during Play.
OnCollisionEndCalled once when a solid contact on this object ends.
OnSensorEnterCalled once when a sensor overlap on this object begins.
OnSensorExitCalled once when a sensor overlap on this object ends.
OnTapWhen this object is tapped during Play.

Attributes ​

MemberDescription
OutputExpose a runtime field read-only in the Inspector and HUD bindings without saving its value.
PropertyExpose and save this field in the Inspector.
RangeInspector limits for a numeric [Property]. It does not clamp assignments in code.
SyncReplicate this private scalar field from the host. Cannot combine with [Property].
ComputedExpose a public zero-argument scalar getter to HUD bindings. Reads state without gameplay side effects.
PureCheck this synchronous component query for direct and transitive side effects.
RepeatChoose parallel, ignore, replace, or queue for repeated async calls.
TestMark a parameterless public bool or async Task<bool> method as an isolated author test.
ComponentIdPreserve a class's authored component identity when renaming.
FlowIdPreserve a public method's authored Flow identity when renaming.
EventIdPreserve a declared event's saved Flow identity when renaming.
CaseIdPreserve a union case's saved identity when renaming.
AssetKindFilter an authored Asset or List<Asset> property picker.
NetworkActionAllow players to request this public synchronous void method. Use Network sender context to enforce gameplay rules on the host.

Example ​

csharp
class Spinner : Component {
    [Property] [Range(0, 360)] float Speed = 90;

    void Update(float dt) {
        Transform.Rotate(Speed * dt);
    }
}

See also ​