URT3D Docs
  • ๐Ÿ“˜Welcome to URT3D Docs
  • Getting Started
    • ๐Ÿš€Quickstart
  • Basics
    • ๐ŸŒIntroduction to URT3D
    • ๐Ÿ”„How to Convert Your Files
    • โฌ†๏ธUpload Tips and Guidelines
    • ๐Ÿ“ฆUsing Your Converted Files
    • ๐Ÿ› ๏ธTroubleshooting Conversion
  • ๐Ÿ“‚ Developers
    • ๐Ÿ‘ฉโ€๐Ÿ’ปGetting Started with the SDK
    • ๐Ÿ‘จโ€๐Ÿ’ปUnity Integration Guide
    • ๐Ÿ—๏ธCore Concepts & Architecture
    • ๐ŸงฌTraits System
    • โœ๏ธScripting System
      • ๐ŸงพMiniScript Recipes
    • ๐Ÿ“˜API Reference
    • ๐Ÿ’กExamples and Best Practices
    • ๐Ÿ›ฐ๏ธAdvanced Topics
Powered by GitBook
On this page
  1. ๐Ÿ“‚ Developers
  2. Scripting System

MiniScript Recipes

MiniScript is a simple yet powerful scripting language embedded in URT3D assets. Use it to define how your asset behaves on load, when interacted with, or in response to custom events.

Below are ready-to-use MiniScript examples categorized by behavior type.


๐Ÿ”„ Animation Control

Play an animation when the asset loads:

anim = GetTrait("Animatable")

function OnStart()
    anim.PlayAnimation("Idle", true)
end function

Switch animations based on custom events:

anim = GetTrait("Animatable")

function OnCustomEvent(name)
    if name == "Jump" then
        anim.PlayAnimation("Jump", false)
    else if name == "Walk" then
        anim.PlayAnimation("Walk", true)
    end if
end function

๐Ÿ‘† Interaction Handling

Respond to a click with a toggle effect:

interactable = GetTrait("Interactable")
active = false

function OnStart()
    interactable.OnClick = OnClick
end function

function OnClick()
    active = not active
    Print("Clicked! State = " + active)
end function

โฑ๏ธ Time-Based Behavior

Delay an animation:

anim = GetTrait("Animatable")

function OnStart()
    Delay(2)
    anim.PlayAnimation("Reveal", false)
end function

Use Update() for floating hover effect:

interactable = GetTrait("Interactable")
position = GetTrait("Position3d")
originalY = position.GetValue().y
hovering = false

function OnStart()
    interactable.OnHoverEnter = OnHoverEnter
    interactable.OnHoverExit = OnHoverExit
end function

function OnHoverEnter()
    hovering = true
end function

function OnHoverExit()
    hovering = false
end function

function Update()
    pos = position.GetValue()
    if hovering then
        pos.y = originalY + 0.2 * Math.Sin(Time.Now * 5)
    else
        pos.y = originalY
    end if
    position.SetValue(pos)
end function

๐Ÿ”— Event Messaging

Trigger an event on another asset:

function OnClick()
    TriggerEventOn("Play_Idle", "npc_001")
end function

๐Ÿงช State Control

Track and reduce health on a custom event:

health = 100

function OnCustomEvent(eventName)
    if eventName == "Damage" then
        health = health - 10
        Print("Health = " + health)
    end if
end function

PreviousScripting SystemNextAPI Reference

Last updated 1 month ago

๐Ÿ’ฌ Have ideas for more recipes? ๐Ÿ“ฉ Email us at

โœ๏ธ
๐Ÿงพ
๐Ÿ—จ๏ธ Join our Discord creator community
support@urt3d.com