API Reference
Important Notes
- In custom scripts, inherit from
CustomBehaviour. - File input/output operations are not available in user scripts.
- Prefer
Start()instead ofAwake()in runtime user scripts. - Press
Ctrl + Alt + Din the client to open the debug window.
Synchronization Variables
Attach SyncObject.cs to objects that should synchronize state across users.
Supported sync types:
SyncStringSyncIntSyncFloatSyncBoolSyncVector2SyncVector3SyncQuaternion
Example:
SyncInt counter;
void Start()
{
counter = new SyncInt(this, "counter");
counter.val = 1;
}
Properties:
valdirtyrestored
Local Variables
Supported local-only types:
LocalIntLocalFloatLocalStringLocalBoolLocalVector2LocalVector3LocalQuaternion
Example:
LocalString localState;
void Start()
{
localState = new LocalString(this, "localState");
localState.val = "ready";
}
Input
GetTouchHand()IsViewTouch()GetGrabHand()IsViewGrab()IsSelected()GetPress(button, hand)GetPressUp(button, hand)GetPressDown(button, hand)GetInputValue(button, hand)GetMouseButton(button)GetMouseDown(button)GetMouseUp(button)Vibration(hand, durationSeconds, frequency, amplitude)
Camera
SetCustomCamera(camera, showUI, useTracking)SetDesktopCamera(camera)ScreenCapture(camera, uicamera, size_x, size_y)ResetCamera()
Media
LoadItemModelAsync(itemId)LoadItemAudioAsync(itemId)LoadItemMotionsAsync(itemIds, model)- This is currently used for VMD / dance-style motion playback.
LoadItemCameraAsync(itemId, cameraObject)SyncExternalMediaAsync(itemId)LoadItemBytesAsync(itemId)
AI
SetNpcViewImage(npc, image)ExecuteNpcChatAsync(npc, userId, dialogue, description, prefix, suffix)- Returns the raw model output string.
AppendNpcChatHistory(npc, text)ExecuteAIStreamAsync(prompt)ExecuteAIStreamLocalAsync(apiKey, prompt)AIVoiceToTextAsync(apiKey, audioString, lang)VoiceToTextAsync(audioData, lang)TranslateTextAsync(text, targetLang)
Voice
SetVoiceEnabled(enable)GetVoiceEnabled()PlayVoiceAudio(userId, audioData)SetVoiceSendingStatus(isSending)SetVoiceCallback(userId, callback)Base64StringToAudioClip(audioString)AudioClipToBase64String(audioClip)TextToNpcSpeech(npcObject, text)
Google API
SpeechToText(audioString, sourceLang, apiKey, callback)TextTranslation(source, sourceLang, targetLang, apiKey, callback)TextToSpeech(source, sourceLang, targetLang, voiceName, gender, apiKey, callback)
User Events
EventUserJoin(user)EventUserLeave(user)
Image Tracking
StartImageBasedTracking(avatar)StopImageBasedTracking()
User Access
GetUsers()GetUserById(id)GetUserByObject(go)GetOwner(go)GetPlayer()
Ownership
IsOwned(go)TakeOwnership(go)
Misc
GoToWorld(worldId, passwd)RetrieveBodyData(go)GetBodyPartObject(user, body)EnableOutline(enable, color, lineWidth)ManualSync()PurchaseProduct(productId)FindInvenItemsByExtensions(extensions)FindItemsInScene(itemName)IsVRModeEnabled()GetGlobalBehaviour()ShowExpandMenu(show)SetObjectInformationDisplay(show)
User Class
User represents a player or remote avatar in the world.
Fields:
userIdavatarObject
Methods:
GetBodyPartObject(bodyPart)GetBodyPartVelocity(bodyPart)PlayAnimation(animationSet, index)PlayAnimation(animationSet, alias)StopAnimation()GetAnimationTimeNormalized()SetPosition(pos)SetRotation(rot)BindToObject(go)IsSpeaking()
Motion Components
These are SDK-visible components for the humanoid motion-pack workflow.
AnimationSet
Stores named animation aliases that can be consumed by runtime helpers.
Main field:
animations
Main helpers:
GetAnimationByName(alias)GetAnimationByIndex(index)GetAnimationIndexByName(alias)GetAnimationClipByName(alias)HasAnimation(alias)
NpcMotionProfile
NPC-specific mapping from AI words to local semantic names.
Main fields:
idleSemantictalkingSemanticwalkingSemanticactionDurationSecondsemotionMapactionMap
Main helpers:
ResolveEmotionSemantic(emotion)ResolveActionSemantic(action)NormalizeKey(value)
NpcDesc
NPC root component.
CharacterMotionController
Runtime execution component that discovers attached AnimationSet components and plays the selected semantic on the target character.
Main field:
animator
Pack helpers:
GetPackNames()HasPack(packName)SetCurrentPack(packName)ResolveActiveAnimationSet()
Semantic helpers:
HasSemantic(semantic)PlaySemantic(semantic)PlaySemantic(semantic, restart)PlaySemantic(semantic, restart, loop, speed)
Motion helpers:
PlayMotion(motionName)PlayMotion(motionName, restart)PlayMotion(motionName, restart, loop, speed)PlayPackMotion(packName, motionName)PlayPackMotion(packName, motionName, restart)PlayPackMotion(packName, motionName, restart, loop, speed)PlayAnimationAlias(alias, loop, speed)PlayAnimationAlias(alias, loop, speed, restart)StopActiveMotion()