Developer reference

Simuspaces ScriptAPI

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

ScriptAPI / Overview

Overview

The ScriptAPI is the runtime scripting layer for Simuspaces worlds. A script is a C# class derived from Simuspaces.Simulation.SimuScriptBase. 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 Simuspaces, dynamic objects and animated mesh do not automatically sync position/states/etc. To sync animation, see the example scripts for animation sync. To sync dynamic objects (rigidbody enabled) all you have to do is add any script to the object, it can even be a just an empty class with the Simuspaces.Simulation include.

ScriptAPI / Core Concepts

Core Concepts

SimuScriptBase

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, SVLight, 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 SVInteractionInfo 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 SVTriggerInfo 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 SVCollisionInfo 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

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

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