Realot StudioDocs
API reference

this (EntityContext) reference

Inside every script callback, `this` represents the entity that owns that script. These are its direct members and component-backed sub-objects.

View as Markdownllms.txt

#Transform shortcuts

Every entity has a Transform. These members read or write its live data; position values use world-space coordinates and rotation is in degrees.

MemberAccessMeaning
x, yRead/writeWorld position coordinates. Writes also update the physics body's position target when a Rigidbody2D is attached.
positionRead/writeGets or assigns an {x, y} object.
rotationRead/writeRotation in degrees. Kinematic bodies receive the script-set rotation target.
scaleX, scaleYRead/writeTransform scale factors.
translate(dx, dy)MethodMoves the entity by a relative world-space offset and synchronizes physics position targeting.
distanceTo(x, y)MethodReturns straight-line distance from the entity to a world-space point.
transformSub-objectAlways available; see TransformAPI.

#Identity, visibility and lifecycle members

MemberAccessMeaning
nameRead-onlyEntity name.
tagRead/writeEntity tag; can be changed while the game runs.
idRead-onlyStable unique entity ID. Prefer this when you need to refer to one exact spawned instance.
visibleRead/writeGets or sets the entity's active/visible state.
enabledRead/writeGets or sets the enabled state of the Script component attached to this entity. Without a Script component, reads as enabled.
destroy()MethodQueues this entity for removal at the end of the current frame; it is not torn down in the middle of the callback.
destroyedRead-onlyTrue after destroy() is queued and before the entity is removed.
hasComponent(componentKey)MethodTests whether the entity currently has a component, for example hasComponent("Rigidbody2D"). Every entity has Transform.
isCloneRead-onlyTrue for the context used by a script on an entity created by runtime spawn().
spawn(nameOrTagOrEntity, opts)MethodCreates a runtime clone. Accepts a name/tag lookup or an EntityContext. See Finding and spawning.
wait(seconds, callback), cancelWait(timerId)MethodsStart and cancel an entity-owned one-shot timer.
repeat(seconds, callback), cancelRepeat(timerId)MethodsStart and cancel an entity-owned repeating timer.
releaseToPool(delay?)MethodReturns a pooled entity to its pool immediately or after an optional delay.
isPooledRead-onlyTrue when the entity was created and is managed by an object pool.

#Pointer and touch helpers

These helpers test the current entity's actual Collider2D shape, not only its bounding rectangle. A Collider2D is required; without one these hit tests cannot match the pointer or a finger.

MemberMeaningInput
isPointerOverTrue while the mouse cursor is over this entity.Mouse hover.
isClickedTrue for the frame the left mouse button is pressed over this entity.Mouse click.
isTouchOverTrue while any active finger is over this entity.Touch hover.
isTappedTrue for the frame a finger first touches down over this entity.Touch tap.
myTouchPer-entity tracking for claiming and following one finger. The sub-object exists on every entity, but hit detection requires Collider2D.See TouchTrackAPI.
MethodRequirementsBehavior
navMoveToward(targetX, targetY, speed?, opts?)NavWorld2D for pathfinding. NavAgent2D is optional but supplies radius, speed, repath, area and avoidance defaults.Finds a path and advances the entity along it. It does not fall back to straight-line movement when no path exists.
navDriveToward(targetX, targetY, speed?, opts?)Car-type CharacterController, NavWorld2D and NavAgent2D for the full vehicle tuning/agent behavior.Follows a path using vehicle steering, lookahead, braking and recovery behavior.

Use Pathfinding and Navigation: complete setup for setup, options and examples.

#Component sub-objects

These modules are available only when the named component is attached to the same entity. Accessing a missing component module or misspelling a member produces a clear runtime API error. The generated complete script-module index lists every exposed member and its read/write or method status.

Script accessRequired componentReference
this.spriteSpriteRendererSpriteRenderer
this.shapeShapeRendererShapeRenderer
this.textTextRendererTextRenderer
this.strokePathStrokePathStrokePath
this.speechBubbleSpeechBubbleSpeechBubble
this.chatChatLogChatLog
this.textInputTextInputTextInput
this.joystickJoystickJoystick
this.rigidbodyRigidbody2DRigidbody2D
this.colliderCollider2DCollider2D
this.jointJoint2DJoint2D
this.controllerCharacterControllerCharacterController
this.animatorSpriteAnimationSpriteAnimation
this.cameraCameraCamera
this.audioAudioSourceAudioSource
this.earAudioListenerAudioListener
this.lightLightLight
this.shadowCasterShadowCasterShadowCaster
this.navAgentNavAgent2DNavAgent2D

#Always-available sub-objects

AccessAvailabilityReference
this.transformEvery entity has Transform.TransformAPI
this.stateEvery entity; no Inspector component. Starts at state default.StateAPI and State & messaging
this.myTouchEvery entity; collider is needed for pointer/finger hit detection.TouchTrackAPI

#Scene-level module

scene.lighting is not attached to this. It exposes scene-wide LightingSettings through the global scene object. When there is no LightingSettings component in the scene, reads use renderer defaults and writes have no effect. See LightingSettingsAPI and LightingSettings.