NexusScript¶
NexusScript is how you make a world do things — open doors, score points, greet players, drive AI NPCs. You write it as .cs files that look like C#, but they're compiled and run by NexusVM, a sandboxed virtual machine. That sandbox is the point: your script can't touch the file system, crash the server, or escape into the host — so worlds from any creator are safe to run.
Your first script¶
A NexusScript is a class that extends NexusBehaviour:
using UnityEngine;
using NexusVM.Unity;
class HelloWorld : NexusBehaviour
{
protected override void Start()
{
Debug.Log("Hello from my world!");
}
void OnTriggerEnter(Collider other)
{
Debug.Log(other.name + " walked into my trigger.");
}
}
It runs through a NexusComponent: you compile the script, and assign the compiled result to a NexusComponent on a GameObject. Lifecycle methods (Start, Update, OnTriggerEnter, …) and your custom methods are called by the runtime.
It's a subset, not full C#/Unity
You get core C#, UnityEngine value types (Vector3, Color…), and a curated set of APIs (below). You don't get arbitrary .NET, reflection, file I/O, or raw networking — those go through the safe APIs instead.
The API surface¶
Everything your script can reach. The platform APIs are SocialScape's own; the engine & Unity APIs are the familiar Unity classes, exposed safely. Every call is also indexed with signatures in the API Reference.
Platform APIs
| API | What it does | Page |
|---|---|---|
| Player.* / Networking.* | Find, read, and control players | Player API |
| NPC.* / Self.* | Drive AI NPCs (speak, act, remember) | NPC & Self API |
| Voice.* | NPC speech & player voice | Voice API |
World Events (NPC.Notify) |
Tell an NPC something happened | World Events |
| Custom Actions | Give the AI tools your script implements | Custom Actions |
| Storage.* | Per‑script key‑value "soft memory" | Storage |
| Http.* / Json.* | Call external services / your DB (server‑side) | HTTP & Supabase |
Engine & Unity APIs
| API | What it does | Page |
|---|---|---|
GameObject, Transform |
Move, rotate, parent, find, spawn objects | GameObjects & Transforms |
Vector3, Quaternion, Mathf, Color, Random |
Vectors, rotations, and math | Math & vectors |
Physics, Rigidbody, Collider, CharacterController |
Raycasts, forces, collisions | Physics |
UI, Button, Text, Slider, Toggle, … |
Build & drive screen UI | UI |
Animator, NavMeshAgent, IK |
Animation & pathfinding | Animation & navigation |
AudioSource, AudioClip |
Play sounds & music | Audio |
Input, Time, Camera, Screen |
Controls, timing, viewpoint | Input, time & camera |
List, Dictionary, HashSet, LINQ |
Collections & queries | Collections & LINQ |
Renderer, Material, Light, ParticleSystem |
Colors, lights, particles, sprites | Rendering & effects |
Debug, lifecycle, the sandbox |
The language subset & ground rules | Basics & lifecycle |
Where scripts run¶
NexusScripts can run on the server (authoritative world logic, AI brains) and replay on clients (visuals). Most of the time you don't think about it — but a few APIs are server‑only (anything that needs secrets or authority, like Player.GetUsername or Http.*). Pages note this where it matters.
→ Start with Basics & lifecycle, or jump to the API you need.