Component
base class in OpalScript
Base type for an OpalScript behavior attached to a scene object.
Properties
| Member | Description |
|---|---|
| Self | This object as a scene-bound Entity. Compare against null before use. |
Methods
| Member | Description |
|---|---|
| GetComponent | Find 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. |
| HasComponent | Whether this entity has an enabled component T. Null or expired entities return false. |
Lifecycle
| Member | Description |
|---|---|
| Start | Once when this component becomes active during Play. |
| Update | Every gameplay frame. dt is elapsed seconds for this object's time group. |
| FixedUpdate | Every physics step. dt is the fixed simulation step for this object's time group. |
| End | Once when this component is removed or Play stops. |
| LocalInput | Each frame on the locally owned object, before Update. |
| OnPlayerJoined | When a player joins the session. The argument is that player's id. |
| OnPlayerLeft | When a player leaves the session. The argument is that player's id. |
| OnCollisionStart | Called once per solid contact transition on this object during Play. |
| OnCollisionEnd | Called once when a solid contact on this object ends. |
| OnSensorEnter | Called once when a sensor overlap on this object begins. |
| OnSensorExit | Called once when a sensor overlap on this object ends. |
| OnTap | When this object is tapped during Play. |
Attributes
| Member | Description |
|---|---|
| Output | Expose a runtime field read-only in the Inspector and HUD bindings without saving its value. |
| Property | Expose and save this field in the Inspector. |
| Range | Inspector limits for a numeric [Property]. It does not clamp assignments in code. |
| Sync | Replicate this private scalar field from the host. Cannot combine with [Property]. |
| Computed | Expose a public zero-argument scalar getter to HUD bindings. Reads state without gameplay side effects. |
| Pure | Check this synchronous component query for direct and transitive side effects. |
| Repeat | Choose parallel, ignore, replace, or queue for repeated async calls. |
| Test | Mark a parameterless public bool or async Task<bool> method as an isolated author test. |
| ComponentId | Preserve a class's authored component identity when renaming. |
| FlowId | Preserve a public method's authored Flow identity when renaming. |
| EventId | Preserve a declared event's saved Flow identity when renaming. |
| CaseId | Preserve a union case's saved identity when renaming. |
| AssetKind | Filter an authored Asset or List<Asset> property picker. |
| NetworkAction | Allow 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);
}
}