Skip to content

Entity ​

class in OpalScript

A live scene object. Missing, disabled, or destroyed references read as null.

Properties ​

MemberDescription
GroupRead-only authored object group.
IdRead-only scene id.
NameRead-only object name.
PositionLocal position in pixels. Writes keep Motion targets in sync, like Transform.Position.
RotationLocal rotation in degrees. Writes keep Motion targets in sync, like Transform.Rotation.
WorldPositionRead-only sprite origin in scene world coordinates.
WorldPointRead-only typed sprite origin in world coordinates.

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.

Example ​

csharp
void OnCollisionStart(Entity other) {
    Health target = other.GetComponent<Health>();
    if (target != null) {
        target.TakeDamage(10);
    }
}

See also ​