Developer reference

TestPlatform5 ScriptAPI

Build interactive objects, player events, triggers, dialogs, animation sync, media screens, and shared world behavior with C# scripts that inherit from ScriptBase.

ScriptAPI / Overview

Overview

The ScriptAPI is the runtime scripting layer for TestPlatform5 worlds. A script is a C# class derived from IHXR.Simulation.ScriptBase. The base class supplies lifecycle callbacks, safe object references, world user events, inter-script messaging, chat command callbacks, client-side visual commands, triggers, collisions, interactables, dialogs, inventory spawning, spritesheet controls, player controls, and logging.

In TestPlatform5, dynamic objects (with a rigidbody) and animated meshes stay in sync for everyone automatically, with no script needed: physics is simulated on the server, and animations play from the server's clock, so every player sees them in the same place at the same moment. Scripts are only needed to change them while the world runs, for example to start, stop or switch an animation for everyone, or to push and move objects; see the Examples.

ScriptAPI / Core Concepts

Core Concepts

ScriptBase

The base class for all user scripts. Override lifecycle callbacks and call protected helper methods from inside your script.

SceneObject

A serialized reference to an object in the scene. It resolves to a GameObject, Transform, and component accessors at runtime.

targetUsername

Most client command helpers can target everyone or one user. Empty, *, all, and everyone apply to every client.

public fields

Public script fields become editable script settings and object slots. Common field types include numbers, strings, booleans, Vector3, Color, SceneObject, Sitpoint, SceneLight, InventoryItem, Emote, and public List<T> rows for repeatable values.

client commands

Renderer, material, audio, light, animation, dialog, transform, and media helpers queue commands for clients. Object-targeted overloads take a SceneObject; self-targeted overloads affect the script object.

ScriptAPI / Workflows

Common Workflows

Clickable Objects

Expose a SceneObject field for the clicked object, then call MakeInteractable in Start. The callback receives InteractionInfo with username, object name, object id, interaction type, and target object.

See interactable examples

Trigger Zones

Call RegisterTrigger on the current object or on a SceneObject slot. The callbacks receive TriggerInfo with enter or exit, player detection, object identity, and resolved scene references.

See trigger examples

Collision Events

Call RegisterCollision on the current object or on a SceneObject slot. The callback receives CollisionInfo with the collided object's name, object id, player detection, and resolved scene reference.

See interaction reference

Object Effects

Use target overloads such as SetLightIntensity(SceneObject,...), PlayAudio(SceneObject,...), SetRendererVisible(SceneObject,...), SetMaterialFloat(SceneObject,...), and SetLocalPosition(SceneObject,...) when the effect belongs to another scene object.

See command reference

Smooth Scripted Movement

Use LerpLocalPosition, LerpLocalRotation, LerpLocalScale, or LerpLocalTransform to send timed waypoints instead of a transform command every frame. Each client interpolates locally, and shared commands follow the same path on the instance server.

See smooth dance-light example

Material Glow

Drive SV Standard Lit emission with _EmissionIntensity and _EmissionColor. Combine this with public List<SceneObject>, List<float>, and List<Color> fields for multi-object glow controls.

See material emission example

Character Physics

Use SetCharacterPhysicsMode, StopCharacterPhysicsMode, and ApplyCharacterImpact to make one targeted user's local avatar fall, drop, recover, or stand normally again.

See character physics example

Shared Script Events

Use PostScriptEvent and ListenForScriptEvent for lightweight messages between scripts. Event names can be global, or grouped with the name@group form.

See event examples

Chat Commands

Use RegisterChatCommand to handle custom slash commands that the game client does not reserve, then call SendScriptChat when the script should add a [Script] room message.

See chat command example