Skip to main content

Lua API Summary

This is the complete public Lua surface available in editor Play Mode and in a PS1 build. Names are case-sensitive. Optional parameters are shown in square brackets. The generated .polygon/lua/POLYGON_LUA_API.md inside a configured project is produced from the same engine declaration and is the exact local reference for that installed build.

Lifecycle Callbacks

CallbackWhen it runs
Awake(gameObjectId)Once after the Lua Behaviour is loaded.
OnEnable(gameObjectId)Whenever the Lua Behaviour becomes active.
Start(gameObjectId)Before the first Update.
FixedUpdate(gameObjectId, fixedDeltaTime)At the bounded 30 Hz simulation step.
Update(gameObjectId, deltaTime)Once per rendered frame.
LateUpdate(gameObjectId, deltaTime)After Update.
OnCollisionEnter(gameObjectId, otherGameObjectId)When a collision starts.
OnCollisionStay(gameObjectId, otherGameObjectId)While a collision remains active.
OnCollisionExit(gameObjectId, otherGameObjectId)When a collision ends.
OnTriggerEnter(gameObjectId, otherGameObjectId)When a trigger overlap starts.
OnTriggerStay(gameObjectId, otherGameObjectId)While a trigger overlap remains active.
OnTriggerExit(gameObjectId, otherGameObjectId)When a trigger overlap ends.
OnDisable(gameObjectId)When the Lua Behaviour becomes inactive.
OnDestroy(gameObjectId)Before script state is released.

Core

Log and Time

MethodReturnsPurpose
Log.Print(message)noneWrites one runtime-safe log line.
Time.DeltaTime()numberReturns the scaled frame delta in seconds.
Time.UnscaledDeltaTime()numberReturns frame delta before time scale is applied.
Time.GetTimeScale()numberReturns the current gameplay time scale.
Time.SetTimeScale(scale)booleanSets time scale in 0.0..4.0; zero pauses scaled simulation while UI, input, and Lua frame callbacks remain active.

Transform

MethodReturnsPurpose
Transform.GetPosition(gameObjectId)Vec3 or nilReads world position.
Transform.SetPosition(gameObjectId, position)booleanSets world position from a Vec3.
Transform.SetPosition(gameObjectId, x, y, z)booleanSets world position from scalars.
Transform.GetPositionX/Y/Z(gameObjectId)number or nilReads one world-position axis.
Transform.GetRotation(gameObjectId)Vec3 or nilReads Euler rotation in degrees.
Transform.SetRotation(gameObjectId, rotation)booleanSets Euler rotation from a Vec3.
Transform.SetRotation(gameObjectId, x, y, z)booleanSets Euler rotation from scalars.
Transform.GetRotationX/Y/Z(gameObjectId)number or nilReads one Euler axis.
Transform.GetScale(gameObjectId)Vec3 or nilReads local scale.
Transform.SetScale(gameObjectId, scale)booleanSets scale from a Vec3.
Transform.SetScale(gameObjectId, x, y, z)booleanSets scale from scalars.
Transform.GetScaleX/Y/Z(gameObjectId)number or nilReads one scale axis.
Transform.RotateX/Y/Z(gameObjectId, degrees)booleanRotates around one axis.
Transform.Translate(gameObjectId, x, y, z)booleanApplies a world-space translation.

Transform setters reject non-finite or out-of-range PS1 values instead of silently corrupting scene state.

GameObject

MethodReturnsPurpose
GameObject.Find(name)integerFinds a GameObject by exact name, including inactive objects in the current implementation, or -1.
GameObject.Exists(gameObjectId)booleanChecks ID validity.
GameObject.GetName(gameObjectId)string or nilReads the display name.
GameObject.IsActive(gameObjectId)boolean or nilReads active state.
GameObject.SetActive(gameObjectId, active)booleanChanges active state.
GameObject.Invoke(gameObjectId, functionName[, int1, int2, string1, string2])booleanCalls a function on the target Lua Behaviour.
GameObject.CompareTag(gameObjectId, tag)booleanCompares a baked tag without allocating.
GameObject.GetLayer(gameObjectId)integerReads the physics/render layer.
GameObject.SetLayer(gameObjectId, layer)booleanChanges the layer inside the baked range.

Input and Feedback

Input

MethodReturnsPurpose
Input.GetButton(buttonOrAction)booleanTests a physical button constant or semantic action.
Input.GetButtonDown(buttonOrAction)booleanTrue only on the pressed frame.
Input.GetButtonUp(buttonOrAction)booleanTrue only on the released frame.
Input.GetAxis([stickOrAction])number, numberReturns normalized X/Y in -1.0..1.0.
Input.IsConnected()booleanReports Port 1 controller connection state.
Input.HasAnalog()booleanReports whether analog input is available.
Input.GetPadType()integerReturns the PS1 controller type code.

Button constants: CROSS, CIRCLE, SQUARE, TRIANGLE, UP, DOWN, LEFT, RIGHT, START, SELECT, L1, L2, L3, R1, R2, and R3. Stick selectors: STICK_LEFT and STICK_RIGHT.

PlayerInput

MethodReturnsPurpose
PlayerInput.SetEnabled(gameObjectId, enabled)booleanChanges runtime PlayerInput state without deactivating the GameObject or LuaBehaviour.
PlayerInput.IsEnabled(gameObjectId)boolean or nilReads runtime state, or returns nil when the component is absent.

Disabling PlayerInput stops native movement, look, interaction, and interaction prompts. Raw Input queries remain active for menus and custom scripting.

Rumble

MethodReturnsPurpose
Rumble.Play([lowFrequency, highFrequency, durationSeconds])booleanStarts bounded vibration.
Rumble.Stop()noneStops vibration.
Rumble.IsSupported()booleanReports vibration capability.

Audio and Presentation

AudioSource and Music

MethodReturnsPurpose
AudioSource.Play(gameObjectId)booleanPlays the assigned resident clip.
AudioSource.PlayOneShot(gameObjectId)booleanStarts an independent one-shot voice for the assigned clip.
AudioSource.Stop(gameObjectId)booleanStops playback.
AudioSource.SetVolume(gameObjectId, volume)booleanSets normalized source volume.
AudioSource.SetPan(gameObjectId, pan)booleanSets stereo pan in -1.0..1.0.
AudioSource.IsPlaying(gameObjectId)booleanReads source playback state.
Music.Play(name[, loop])booleanStarts a named streamed CD-XA track.
Music.Stop()booleanStops streamed music.
Music.SetVolume(volume)booleanSets streamed-music volume.
Music.IsPlaying()booleanReads streamed-music state.

Camera

MethodReturnsPurpose
Camera.Has(gameObjectId)booleanChecks for a Camera component.
Camera.GetActive()integerReturns the active Camera GameObject.
Camera.GetFieldOfView(gameObjectId)number or nilReads vertical field of view.
Camera.SetFieldOfView(gameObjectId, degrees)booleanSets vertical field of view.

Light

MethodReturnsPurpose
Light.Has(gameObjectId)booleanChecks for a Light component.
Light.GetDirection(gameObjectId)Vec3 or nilReads light direction.
Light.SetDirection(gameObjectId, x, y, z)booleanSets light direction.
Light.GetColor(gameObjectId)RGB table or nilReads 8-bit directional color.
Light.SetColor(gameObjectId, r, g, b)booleanSets 8-bit directional color.
Light.GetIntensity(gameObjectId)number or nilReads intensity.
Light.SetIntensity(gameObjectId, intensity)booleanSets intensity.
Light.GetAmbient(gameObjectId)RGB table or nilReads 8-bit ambient color.
Light.SetAmbient(gameObjectId, r, g, b)booleanSets 8-bit ambient color.

ParticleSystem

MethodReturnsPurpose
ParticleSystem.Emit(x, y, z, vx, vy, vz, lifetime[, r, g, b])noneEmits one bounded billboard particle.
ParticleSystem.Clear()noneClears all emitted particles.

Physics and Movement

Collider

Collider.ShapeBox and Collider.ShapeSphere identify the supported shapes.

MethodReturnsPurpose
Collider.Has(gameObjectId)booleanChecks for a Collider.
Collider.GetShape(gameObjectId)integer or nilReads the shape constant.
Collider.SetShape(gameObjectId, shape)booleanSets a supported shape.
Collider.IsTrigger(gameObjectId)booleanReads trigger state.
Collider.SetIsTrigger(gameObjectId, isTrigger)booleanChanges trigger state.
Collider.GetSize(gameObjectId)Vec3 or nilReads box size.
Collider.SetSize(gameObjectId, x, y, z)booleanSets box size.
Collider.GetRadius(gameObjectId)number or nilReads sphere radius.
Collider.SetRadius(gameObjectId, radius)booleanSets sphere radius.

Physics

MethodReturnsPurpose
Physics.IsColliding(gameObjectId[, otherGameObjectId])booleanTests any collision or a specific pair.
Physics.GetCollisionCount(gameObjectId)integerCounts active collisions.
Physics.Raycast(ox, oy, oz, dx, dy, dz, maxDistance[, layerMask, queryTriggers])hit, ID, point XYZ, normal XYZ, distancePerforms an allocation-free raycast.

CharacterController

MethodReturnsPurpose
CharacterController.Move(gameObjectId, x, y, z)booleanMoves through the kinematic collision world.
CharacterController.IsGrounded(gameObjectId)booleanReads grounded state.
CharacterController.GetVelocityY(gameObjectId)numberReads vertical velocity.
CharacterController.SetVelocityY(gameObjectId, velocity)booleanSets vertical velocity.

Scenes, Navigation, and Interaction

SceneManager

MethodReturnsPurpose
SceneManager.LoadScene(scenePath)noneQueues a transition to a scene included in Build Settings.

NavMeshAgent.PathInvalid and NavMeshAgent.PathComplete are the current path status constants.

MethodReturnsPurpose
NavMesh.FindPath(sx, sy, sz, ex, ey, ez)tableReturns a complete path of at most 32 Vec3 points, or an empty table.
NavMesh.SamplePosition(x, y, z, maxDistance[, surfaceGameObjectId])found, x, y, zFinds the nearest point on a baked NavMesh.
NavMeshAgent.SetDestination(gameObjectId, x, y, z)booleanStarts movement toward a complete path destination.
NavMeshAgent.Stop(gameObjectId)noneStops and clears agent movement.
NavMeshAgent.IsMoving(gameObjectId)booleanReads active movement state.
NavMeshAgent.HasPath(gameObjectId)booleanReports whether a valid path is owned.
NavMeshAgent.HasReachedDestination(gameObjectId)booleanTests the stopping distance.
NavMeshAgent.IsOnNavMesh(gameObjectId)booleanTests binding to a baked surface.
NavMeshAgent.GetRemainingDistance(gameObjectId)numberReads bounded remaining path distance.
NavMeshAgent.GetSpeed(gameObjectId)numberReads current movement speed.
NavMeshAgent.GetPathStatus(gameObjectId)integerReads a path status constant.

Portal and Interactable

MethodReturnsPurpose
Portal.SetOpen(portalGameObjectId, open)booleanChanges Room connectivity through a Portal.
Interactable.SetEnabled(gameObjectId, enabled)booleanChanges built-in interaction state.
Interactable.IsEnabled(gameObjectId)booleanReads built-in interaction state.

Animation and Timelines

MethodReturnsPurpose
Timeline.Play(name[, { OnComplete = fn }])booleanStarts an authored Timeline.
Timeline.Stop()noneStops the active Timeline.
Timeline.IsPlaying()booleanReads Timeline state.
Animation.Play(name[, loop])booleanStarts an authored standalone clip.
Animation.Play(name[, { Loop = bool, OnComplete = fn }])booleanStarts a clip with options.
Animation.Stop([name])noneStops one clip or every clip.
Animation.IsPlaying([name])booleanTests one clip or any clip.
TransformAnimator.Play(gameObjectId[, state])booleanStarts a transform state.
TransformAnimator.Stop(gameObjectId)booleanStops transform animation.
TransformAnimator.SetSpeed(gameObjectId, speed)booleanChanges playback speed.
TransformAnimator.IsPlaying(gameObjectId)booleanReads playback state.
TransformAnimator.SetState(gameObjectId, state)booleanSelects an authored state.
TransformAnimator.GetState(gameObjectId)string or nilReads the selected state.
Animator.Play(gameObjectId, clipName[, loop])booleanStarts an imported skeletal clip.
Animator.Stop(gameObjectId)booleanStops skeletal playback.
Animator.IsPlaying(gameObjectId)booleanReads skeletal playback state.
Animator.GetClip(gameObjectId)string or nilReads the active clip name.
Animator.ConsumeFinished(gameObjectId)string or nilConsumes the finished non-looping clip name.

Authored UI

TableMethods
UIFind(name), GetType(elementId), GetCount(), DrawText(x, y, text)
CanvasFind(name), SetEnabled(canvasId, enabled), IsEnabled(canvasId), SetSortOrder(canvasId, order), GetCount()
TextSetText(elementId, text), GetText(elementId)
ImageSetTexture(elementId, textureGuid), GetTexture(elementId)
ButtonSetInteractable(elementId, interactable), IsInteractable(elementId)
RectTransformSetPosition(elementId, x, y), GetPosition(elementId), SetSize(elementId, width, height), GetSize(elementId)
GraphicSetColor(elementId, r, g, b[, a]), GetColor(elementId), SetEnabled(elementId, enabled), IsEnabled(elementId)
SelectableSelect(elementId), GetSelected()
ProgressBarSetValue(elementId, value), GetValue(elementId)

UI.DrawText is transient debug output. Use authored Text elements for player UI. UI element IDs are global within the scene; Canvas IDs belong to the Canvas collection.

Persistence

PlayerPrefs

MethodReturnsPurpose
PlayerPrefs.SetInt(key, value)booleanStores an integer.
PlayerPrefs.GetInt(key[, defaultValue])integerReads an integer.
PlayerPrefs.SetFloat(key, value)booleanStores a finite float.
PlayerPrefs.GetFloat(key[, defaultValue])numberReads a float.
PlayerPrefs.SetString(key, value)booleanStores a string.
PlayerPrefs.GetString(key[, defaultValue])stringReads a string.
PlayerPrefs.HasKey(key)booleanChecks for a typed preference.
PlayerPrefs.DeleteKey(key)booleanDeletes one typed preference.
PlayerPrefs.DeleteAll()booleanDeletes only PlayerPrefs entries.
PlayerPrefs.Save()booleanFlushes preferences to the platform save device.

SaveData

MethodReturnsPurpose
SaveData.Write(key, value)booleanWrites an advanced raw string value.
SaveData.Read(key)string or nilReads a raw value.
SaveData.Flush()booleanFlushes raw data to the platform save device.
SaveData.Clear()noneClears all raw and typed entries in memory.
SaveData.Reload()booleanReloads from the platform save device.
SaveData.GetLastError()stringReads the latest persistence failure.

Engine Identity

ValueTypePurpose
Engine.NamestringRuntime implementation name.
Engine.ApiVersionintegerCompatibility identifier for the installed scripting contract.

Use Authoring Workflow for tooling and bytecode behavior, and the topic pages for component setup, examples, and PS1-specific constraints.

For exact argument and return-type declarations, including every scalar-axis method, see the generated API Contract.