Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
bool Enabled get set
Is this Animation State enabled?
float Length get
Returns the length of current animation.
string Name get
Returns the name of current animation.
float NormalizedSpeed get set
Returns the normalized speed of current animation.
float NormalizedTime get set
Returns the normalized time of current animation.
float Speed get set
The playback speed of the animation. 1.0 is normal playback speed.
float Time get set
Returns the Time of current animation.
float Weight get set
Returns the Weight of current animation.
bool Enabled get set
float Length get
string Name get
float NormalizedSpeed get set
float NormalizedTime get set
float Speed get set
float Time get set
float Weight get set
SAnimationState = Space.Host.ExecutingObject.Animation.GetState()
SAnimationState.Enabled = falseSAnimationState = Space.Host.ExecutingObject.Animation.GetState()
length = SAnimationState.LengthSAnimationState = Space.Host.ExecutingObject.Animation.GetState()
name = SAnimationState.NameSAnimationState = Space.Host.ExecutingObject.Animation.GetState()
normalizedSpeed = SAnimationState.NormalizedSpeedSAnimationState = Space.Host.ExecutingObject.Animation.GetState()
normalizedTime = SAnimationState.NormalizedTimeSAnimationState = Space.Host.ExecutingObject.Animation.GetState()
SAnimationState.Speed = 0.5SAnimationState = Space.Host.ExecutingObject.Animation.GetState()
SAnimationState.Time = 0.5SAnimationState = Space.Host.ExecutingObject.Animation.GetState()
SAnimationState.Weight = 0.5commandbuffer=Space.PostFX.CreateCommandBuffer()
mat=Space.Resources[1]
cube=Space.Host.GetReference("Cube")
commandbuffer.DrawRenderer(cube.Renderer,mat.AsMaterial)
Space.PostFX.AddCommandBufferToCamera(commandbuffer)commandbuffer=Space.PostFX.CreateCommandBuffer()
mat=Space.Resources[1]
commandbuffer.Blit(mat.AsMaterial)
Space.PostFX.AddCommandBufferToCamera(commandbuffer)STuneIn TuneIn get set
List< SMusicStation > Station get set
example 1example 2example 1example 2int get
long get
string get
int Rank get
Property Description
example 1example 2long Score get
Property Description
string Username get
Property Description
int get
int get
string get
int RegionID get
Property Description
example 1example 2int Count get
Property Description
string ServerLocation get
Property Description
string get
string get
string get
string Type get
Property Description
tableOfSSocialMedia = Space.Profile.ActivePlayerProfile.SocialMediaProfiles
profileType = tableOfSSocialMedia[1].Typestring MediaID get
Property Description
string Url get
Property Description
bool IsName (string name)
Does name match the name of the active state in the statemachine?
bool IsTag (string tag)
Does tag match the tag of the active state in the statemachine.
int fullPathHash get
The full path hash for this state. The hash is generated using Animator.StringToHash.
int nameHash get
The hashed name of the State.
int shortNameHash get
The hash is generated using SAnimator.StringToHash. The hash does not include the name of the parent layer.
float normalizedTime get
Normalized time of the State. The integer part is the number of time a state has been looped. The fractional part is the % (0-1) of progress in the current loop.
float length get
Current duration of the state. In seconds Can vary when the State contains a Blend Tree.
float speed get
The playback speed of the animation. 1 is the normal playback speed. A negative playback speed will play the animation from the end.
float speedMultiplier get
_The speed multiplier for this state.
A negative speed multiplier will play the animation backwards. If no speed parameter as been set for this SAnimatorState, the default value will be 1._
int tagHash get
_The Tag of the State.
The hash is generated using SAnimator.StringToHash._
bool loop get
Is the state looping. All animations in the state must be looping.
float Length get
Current duration of the state. In seconds Can vary when the State contains a Blend Tree
example 1example 2example 1example 2example 1example 2example 1example 2tableOfSSocialMedia = Space.Profile.ActivePlayerProfile.SocialMediaProfiles
profileID = tableOfSSocialMedia[1].MediaIDtableOfSSocialMedia = Space.Profile.ActivePlayerProfile.SocialMediaProfiles
profileType = tableOfSSocialMedia[1].Urlstring Title get
string Artist get
otc = function(trackInfo)
Space.Log(trackInfo.Title)
end
Space.Host.ExecutingObject.Radio.OnTrackChange(otc)void GetPreview (Closure onComplete)
int ID get
string Name get
example 1example 2string Base get set
string Basem3u get set
string Basexspf get set
example 1example 2string Error
string Response
function ResponseFunction(responseData)
stringError = responseData.Error
end
Space.WebServices.Get('aURL', ResponseFunction)otc = function(trackInfo)
Space.Log(trackInfo.Artist)
end
Space.Host.ExecutingObject.Radio.OnTrackChange(otc)example 1example 2example 1example 2example 1example 2example 1example 2function ResponseFunction(responseData)
stringResponse = responseData.Response
end
Space.WebServices.Get('aURL', ResponseFunction)override string ()
string get set
string get set
string get set
string get set
override string ToString ()
Function Description
example 1string Name get set
Property Description
string ID get set
Property Description
string HasChildren get set
Property Description
string ParentID get set
Property Description
float get
SLandmarkType get
string Name get
Landmark's Name
LandmarkName = Space.Scene.Landmarks[1].NameSVector Position get
Landmark's Position
SQuaternion Rotation get
Landmark's Rotation
bool SpawnPoint get
Is this Landmark a spawn point?
float SpawnRadius get
The size of the radius around the Landmark where players spawn within
int Type get
The type of Landmark 1= LandingZone, 2= Area, 3= Shop, 4= Quest,5= Activity, 6= Teleport, 7= Music, 8= Dance, 9= Clothes, 10= Vehicle, 11= Item
string Name get
SVector Position get
SQuaternion Rotation get
bool get
bool IsName (string name)
bool IsTag (string tag)
int fullPathHash get
int nameHash get
int shortNameHash get
float normalizedTime get
float length get
float speed get
float speedMultiplier get
int tagHash get
bool loop get
float get
int Level get
The level of current activity.
SScore[] AllTimeLeaderboard get
The AllTimeLeaderboard of current activity.
SScore[] DailyLeaderboard get
The daily Leaderboard of current activity.
SScore AllTimePlayerRecord get
The AllTimePlayerRecord of current activity.
SScore DailyPlayerRecord get
The daily player records of current activity.
bool StoreCustomData (string data)
Updates the inventory items custom data, and requests a synchronisation with the inventory server. It may not update on the server immediately, but all local calls will reflect the new data. Note: this request can be rate limited and should only be called from a user initiated action (such as clicking a button). Updates to custom data must not be initiated on a timer or regular automatic event. Access to this function can be blacklisted to specific creators if abused.
void Use ()
Player will 'Use' this item. (White-label only)
void Delete ()
Player will 'Delete' this item. (White-label only)
long MasterID get
The master ID for this item - also known as the Curator ID or Item ID, this is the ID for the master item from which this copy exists.
long PlayerItemID get
The instance ID for this item - this is guaranteed to be unique per inventory item
string Name get
Returns the name of the inventory item
string Description get
Returns the registered description of the inventory item in the users locale
string Brand get
Returns brand information about the item
string CustomData get
Returns any custom data associated with this item, typically used for 'game' items
example 2example 1example 2example 1example 2example 1example 2example 1example 2LandmarkPosition = Space.Scene.Landmarks[1].PositionLandmarkRotation = Space.Scene.Landmarks[1].RotationLandmarkSpawnPoint = Space.Scene.Landmarks[1].SpawnPointLandmarkSpawnRadius = Space.Scene.Landmarks[1].SpawnRadiusLandmarkType = Space.Scene.Landmarks[1].TypeAnimationStateInfo = Space.Host.ExecutingObject.Animator.GetCurrentAnimationStateInfo(0)
AnimationStateInfo.isName("aStateName")AnimationStateInfo = Space.Host.ExecutingObject.Animator.GetCurrentAnimationStateInfo(0)
AnimationStateInfo.isTag("aStateTag")AnimationStateInfo = Space.Host.ExecutingObject.Animator.GetCurrentAnimationStateInfo(0)
fullPathHash = AnimationStateInfo.fullPathHashAnimationStateInfo = Space.Host.ExecutingObject.Animator.GetCurrentAnimationStateInfo(0)
nameHash= AnimationStateInfo.nameHashAnimationStateInfo = Space.Host.ExecutingObject.Animator.GetCurrentAnimationStateInfo(0)
shortNameHash= AnimationStateInfo.shortNameHashAnimationStateInfo = Space.Host.ExecutingObject.Animator.GetCurrentAnimationStateInfo(0)
normalizedTime= AnimationStateInfo.normalizedTimeAnimationStateInfo = Space.Host.ExecutingObject.Animator.GetCurrentAnimationStateInfo(0)
length= AnimationStateInfo.lengthAnimationStateInfo = Space.Host.ExecutingObject.Animator.GetCurrentAnimationStateInfo(0)
speed= AnimationStateInfo.speedAnimationStateInfo = Space.Host.ExecutingObject.Animator.GetCurrentAnimationStateInfo(0)
speedMultiplier= AnimationStateInfo.speedMultiplierAnimationStateInfo = Space.Host.ExecutingObject.Animator.GetCurrentAnimationStateInfo(0)
tagHash= AnimationStateInfo.tagHashAnimationStateInfo = Space.Host.ExecutingObject.Animator.GetCurrentAnimationStateInfo(0)
loop= AnimationStateInfo.loopAnimationStateInfo = Space.Host.ExecutingObject.Animator.GetCurrentAnimationStateInfo(0)
Length= AnimationStateInfo.Lengthuint SenderID get
string Sender get
string Channel get
string Message get
function oc(chatm)
Space.Log(chatm.SenderID)
end
Space.Network.Chat.OnChat(oc)--this script processes every new chat message and makes a UIText display the Sender's ID
uiText = Space.Host.GetReference("text").UIText --Add this Text object as reference in Scripting Runtime
OnChatFunction = function(SChatMessage)
uiText.Text = SChatMessage.SenderID
end
Space.Network.Chat.OnChat(OnChatFunction) int Level get
SScore[] AllTimeLeaderboard get
SScore[] DailyLeaderboard get
SScore AllTimePlayerRecord get
SScore DailyPlayerRecord get
Space.Activity.FinishActivity(99956,100,0,function (rank)
Space.Log(rank.Level)
end)bool StoreCustomData (string data)
void Use ()
void Delete ()
long MasterID get
long PlayerItemID get
string Name get
string Description get
string Brand get
string CustomData get
SVector Origin get
SVector Direction get
ray=Space.Camera.ScreenCoordinatesToRay(Vector.New(0.5,0.5,0))
rayOrigin = ray.Origin --this script will make this object jump to wherever you right click
--(Example: moving objects with right click )
thisGameObject = Space.Host.ExecutingObject
OnUpdate = function()
if Space.Input.GetMouseDown(1) then
clickRay = Space.Camera.ScreenCoordinatesToRay(Space.Input.MousePosition)
rayCastHit = Space.Physics.RayCastSingle(clickRay.Origin, clickRay.Direction, 50.0)
thisGameObject.WorldPosition = rayCastHit.Position
end
end
thisGameObject.SubscribeToEvents()
thisGameObject.OnUpdate(OnUpdate) function oc(chatm)
Space.Log(chatm.Sender)
end
Space.Network.Chat.OnChat(oc)--this script processes every new chat message and makes a UIText display the Sender name
uiText = Space.Host.GetReference("text").UIText --Add this Text object as reference in Scripting Runtime
OnChatFunction = function(SChatMessage)
uiText.Text = SChatMessage.Sender
end
Space.Network.Chat.OnChat(OnChatFunction) function oc(chatm)
Space.Log(chatm.Channel)
end
Space.Network.Chat.OnChat(oc)--this script processes every new chat message and makes a UIText display the channel's name
uiText = Space.Host.GetReference("text").UIText --Add this Text object as reference in Scripting Runtime
OnChatFunction = function(SChatMessage)
uiText.Text = SChatMessage.Channel
end
Space.Network.Chat.OnChat(OnChatFunction) function oc(chatm)
Space.Log(chatm.Message)
end
Space.Network.Chat.OnChat(oc)--this script processes every new chat message and makes a UIText display the Message
uiText = Space.Host.GetReference("text").UIText --Add this Text object as reference in Scripting Runtime
OnChatFunction = function(SChatMessage)
uiText.Text = SChatMessage.Message
end
Space.Network.Chat.OnChat(OnChatFunction) Space.Activity.FinishActivity(99956,100,0,function (rank)
local leaderBoard=rank.AllTimeLeaderboard
for i=1,#leaderBoard do
Space.Log(leaderBoard[i].Rank)
Space.Log(leaderBoard[i].Score)
Space.Log(leaderBoard[i].Username)
end
end)Space.Activity.FinishActivity(99956,100,0,function (rank)
local leaderBoard=rank.DailyLeaderboard
for i=1,#leaderBoard do
Space.Log(leaderBoard[i].Rank)
Space.Log(leaderBoard[i].Score)
Space.Log(leaderBoard[i].Username)
end
end)Space.Activity.FinishActivity(99956,100,0,function (rank)
local record=rank.AllTimePlayerRecord
Space.Log(record.Rank)
Space.Log(record.Score)
Space.Log(record.Username)
end)Space.Activity.FinishActivity(99956,100,0,function (rank)
local record=rank.DailyPlayerRecord
Space.Log(record.Rank)
Space.Log(record.Score)
Space.Log(record.Username)
end)Items = Space.Inventory.Items
Items[1].StoreCustomData('data1data2data3')Items = Space.Inventory.Items
Items[1].Use() Items = Space.Inventory.Items
Items[1].Delete()Items = Space.Inventory.Items
iMasterID = Items[1].MasterIDItems = Space.Inventory.Items
iPlayerItemID= Items[1].PlayerItemIDItems = Space.Inventory.Items
iName= Items[1].NameItems = Space.Inventory.Items
iDescription=Items[1].DescriptionItems = Space.Inventory.Items
iBrand = Items[1].BrandItems = Space.Inventory.Items
iCustomData = Items[1].CustomDataray=Space.Camera.ScreenCoordinatesToRay(Vector.New(0.5,0.5,0))
rayDirection = ray.Direction --this script will make this object jump to wherever you right click
--(Example: moving objects with right click )
thisGameObject = Space.Host.ExecutingObject
OnUpdate = function()
if Space.Input.GetMouseDown(1) then
clickRay = Space.Camera.ScreenCoordinatesToRay(Space.Input.MousePosition)
rayCastHit = Space.Physics.RayCastSingle(clickRay.Origin, clickRay.Direction, 50.0)
thisGameObject.WorldPosition = rayCastHit.Position
end
end
thisGameObject.SubscribeToEvents()
thisGameObject.OnUpdate(OnUpdate) SGameObject get
SVector get
SVector get
SVector get
SVector get
float get
bool get
SGameObject Object get
Property Description
this = Space.Host.ExecutingObject
hit = Space.Physics.RayCastSingle(this.WorldPosition,this.Forward,20)
hitGameObject = hit.ObjectSVector Position get
Where the physics hit occurred
SVector Normal get
The normal of the hit
SVector UV get
The UV coordinates of where the hit occurred on a mesh.
This property will currently always return [0,0] due to a current bug.
SVector UV2 get
The UV2 coordinates of where the hit occurred on a mesh.
This property will currently always return [0,0] due to a current bug.
float Distance get
How far down a ray or from the collider, the hit occurred
bool ContainsHit get
Whether it was a hit or not
override string ()
string get set
string get set
string get set
string get set
string get set
string get set
string get set
string get set
string get set
override string ToString ()
Function Description
string Name get set
Property Description
string Mt get set
Property Description
string Id get set
Property Description
string Br get set
Property Description
string Genre get set
Property Description
string Genre2 get set
Property Description
string Logo get set
Property Description
string Ct get set
Property Description
string Lc get set
Property Description
int get
int get
int get
int get
string get
SPublicRegion[] get
int SubscriptionTier get
The subscription tier indicates which type of premium memberhsip the player has. (As found in "Region" window)
--Make's a UIText show this User's Regions' current Subscription Tier
textObject = Space.Host.GetReference("TheTextReference") --add to References section in Scripting Runtime
function GetUserRegionsComplete(SUserRegions)
local r = SUserRegions.SubscriptionTier
text.UIText.Text = r
end
int NumberOfRegions get
The number of regions the player has. (As found in "Region" window)
int UsersPerRegion get
The max number of users allowed per region. ("Concurrency" as found in "Region" window).
int FileSize get
The maximum MB size the player's regions can be. ("Max Region SizE" in the "Region" window)
string SubscriptionName get
The name of the current player's premium subscription (as found in "Region" window)
SPublicRegion[] AvailableRegions get
Returns an array of SPublicRegion which is a group of data for each of the user's available regions.
string get
string get
string get
SGameObject get
SMaterial get
float get
float get
string Name get
Returns the name of the resource as entered in the scripting runtime
ResourceName = Space.Resources[1].Name--the below script will search through the Scripting Runtime's resources
--and return the first instance of an Animation Clip
--[You need to add a few resources to the scripting runtime and make one of them an animation]
resources = Space.Resources
for i = 1, #resources do
if resources[i].Type == "AnimationClip" then
string Type get
Returns the type of the resource as a string
string AsText get
Converts the resource's type from SResource type to string
SGameObject AsGameObject get
Property Description
SMaterial AsMaterial get
Converts the resource's type from SResource to SMaterial
float TextureWidth get
Returns the Texture Width of this resource
float TextureHeight get
Returns the Texture Height of this resource
void (Closure onLoad)
void (Closure onLoad, int parentId=0)
void (SGenre genre, Closure onLoad)
void (string search, Closure onLoad)
void GetTop100 (Closure onLoad)
Function Description
example 1example 2void GetGenreList (Closure onLoad, int parentId=0)
Function Description
void SearchByGenre (SGenre genre, Closure onLoad)
Function Description
void SearchByText (string search, Closure onLoad)
Function Description
example 2this = Space.Host.ExecutingObject
hit = Space.Physics.RayCastSingle(this.WorldPosition,this.Forward,20)
hitPosition = hit.Positionthis = Space.Host.ExecutingObject
hit = Space.Physics.RayCastSingle(this.WorldPosition,this.Forward,20)
hitNormal = hit.Normalthis = Space.Host.ExecutingObject
hit = Space.Physics.RayCastSingle(this.WorldPosition,this.Forward,20)
hitUV = hit.UVthis = Space.Host.ExecutingObject
hit = Space.Physics.RayCastSingle(this.WorldPosition,this.Forward,20)
hitUV2 = hit.UV2this = Space.Host.ExecutingObject
hit = Space.Physics.RayCastSingle(this.WorldPosition,this.Forward,20)
hitDistance = hit.Distancethis = Space.Host.ExecutingObject
hit = Space.Physics.RayCastSingle(this.WorldPosition,this.Forward,20)
hitContainsHit = hit.ContainsHitexample 1example 2example 1example 2example 1example 2example 1example 2example 1example 2example 1example 2example 1example 2example 1example 2example 1example 2example 1example 2--Make's a UIText show this User's Regions' current NumberOfRegions
textObject = Space.Host.GetReference("TheTextReference") --add to References section in Scripting Runtime
function GetUserRegionsComplete(SUserRegions)
local r = SUserRegions.NumberOfRegions
text.UIText.Text = r
end
Space.Grid.GetEnabledUserRegions(GetUserRegionsComplete)--Make's a UIText show this User's Regions' current UsersPerRegion
textObject = Space.Host.GetReference("TheTextReference") --add to References section in Scripting Runtime
function GetUserRegionsComplete(SUserRegions)
local r = SUserRegions.UsersPerRegion
text.UIText.Text = r
end
Space.Grid.GetEnabledUserRegions(GetUserRegionsComplete)--Make's a UIText show this User's Regions' current FileSize
textObject = Space.Host.GetReference("TheTextReference") --add to References section in Scripting Runtime
function GetUserRegionsComplete(SUserRegions)
local r = SUserRegions.FileSize
text.UIText.Text = r
end
Space.Grid.GetEnabledUserRegions(GetUserRegionsComplete)--Make's a UIText show this User's Regions' current SubscriptionName
textObject = Space.Host.GetReference("TheTextReference") --add to References section in Scripting Runtime
function GetUserRegionsComplete(SUserRegions)
local r = SUserRegions.SubscriptionName
text.UIText.Text = r
end
Space.Grid.GetEnabledUserRegions(GetUserRegionsComplete)--Make's a UIText show the Name of the user's first available region
textObject = Space.Host.GetReference("TheTextReference")
function GetUserRegionsComplete(SUserRegions)
local r = SUserRegions.AvailableRegions[1]
textObject.UIText.Text = r.Name
end
Space.Grid.GetEnabledUserRegions(GetUserRegionsComplete)ResourceType = Space.GetResource("Resource Name").Type--the below script will search through the Scripting Runtime's resources
--and return the first instance of an Animation Clip
--[You need to add a few resources to the scripting runtime and make one of them an animation]
resources = Space.Resources
for i = 1, #resources do
if resources[i].Type == "AnimationClip" then
Space.Log("Resource #".. i .. " is an Animation Clip. The resource name is: " .. resources[i].Name)
break
end
endText = Space.GetResource("Resource Name").AsTextGameObject = Space.GetResource("Resource Name").AsGameObjectMaterial = Space.GetResource("Resource Name").AsMaterialTextureWidth = Space.GetResource("Resource Name").TextureWidthTextureHeight = Space.GetResource("Resource Name").TextureHeightexample 1example 2example 1example 2example 1example 2override string ()
static SJointSpring (float spring, float damper, float targetPosition)
float get
float get
float get
override string ToString ()
Returns this SJointSpring's properties as a string
SpringString = Space.Host.ExecutingObject.HingeJoint.Spring.ToString()static SJointSpring New (float spring, float damper, float targetPosition)
Creates a new SJointSpring with the given spring, damper, targetPosition.
float Springget
The spring forces used to reach the target position.
float Damperget
The damper force uses to dampen the spring.
float TargetPositionget
The target position the joint attempts to reach.
void (params string[] layerNames) void (Table layerNames)
void (string layerName)
void (string layerName)
Static Functions
static SLayerMask (Table layerNames) static SLayerMask (params string[] layerNames)
bool get set
Is the mask exclusionary or not.
string[] get set
The layer names represented in this layer mask
void SetLayers (params string[] layerNames) void SetLayers (Table layerNames)
_Function that changes an existing layer mask _
void AddLayer (string layerName)
Add a new layer to an existing layer mask.
void RemoveLayer (string layerName)|
Remove a new layer from an existing layer mask.
static SLayerMask New (Table layerNames) static SLayerMask New (params string[] layerNames)
Static function that creates a new layer mask
bool Inverted get set
Is the mask exclusionary or not.
string[] Layers get set
The layer names represented in this layer mask
override string ToString ()
Returns this SJointMotor's properties as a string
static SJointMotor New (float targetVelocity, float force, bool freeSpin)
Creates a new SJointMotor with the given targetVelocity, force, freeSpin.
float TargetVelocityget
The motor will apply a force up to force to achieve targetVelocity.
float Forceget
The motor will apply a force.
bool FreeSpinget
If freeSpin is enabled the motor will only accelerate but never slow down.
string UserName get
Get player profile's Username
string Title get
Get player profile's Title
string RealName get
Get player profile's Real Name
string Gender get
Get player profile's Gender
string Since get
Get player profile's Since
string Country get
Get player profile's Country
string City get
Get player profile's City
int SocialGold get
Get player profile's Gold Badge count
int SocialSilver get
Get player profile's Silver Badge count
int SocialFlower get
Get player profile's Flower count
string Interests get
Get player profile's Interests
string About get
Get player profile's About
[] SocialMediaProfiles get
Get player profile's Social Media Profiles
--the below script will make a UI Text element display this GameObjects Hinge Joint Spring properties
--[Add "thetext" and "thehingejoint" reference to the Scripting Runtime component]
thisObject = Space.Host.ExecutingObject
text = Space.Host.GetReference("thetext").UIText
hingejoint = Space.Host.GetReference("thehingejoint").HingeJoint
function OnUpdateFunction()
spring = hingejoint.Spring
text.Text = spring.ToString()
end
thisObject.OnUpdate(OnUpdateFunction)Motor= Space.Host.ExecutingObject.HingeJoint.Spring.New(1,2,3)--the below script will change all Hinge Joint Spring properties to 0 when clicked
--[Add "thehingejoint" reference to the Scripting Runtime component]
thisObject = Space.Host.ExecutingObject
hingejoint = Space.Host.GetReference("thehingejoint").HingeJoint
function OnClickFunction()
spring = hingejoint.Spring
hingejoint.Spring = spring .New(0,0,0)
end
thisObject.AddClickable()
thisObject.Clickable.OnClick(OnClickFunction)SpringSpring= Space.Host.ExecutingObject.HingeJoint.Spring.Spring--the below script will make a slider change a Hinge Joint Spring Spring property
--[Add "theslider" and "thehingejoint" reference to the Scripting Runtime component]
slider = Space.Host.GetReference("theslider").UISlider
hingejoint = Space.Host.GetReference("thehingejoint").HingeJoint
OVC = function()
spring = hingejoint.Spring
spring.Spring = (slider.Value * 10.0) -- from 0.0 to 10.0
hingejoint.Spring= spring
end
slider.OnValueChanged(OVC)SpringDamper= Space.Host.ExecutingObject.HingeJoint.Spring.Damper--the below script will make a slider change a Hinge Joint Spring Damper property
--[Add "theslider" and "thehingejoint" reference to the Scripting Runtime component]
slider = Space.Host.GetReference("theslider").UISlider
hingejoint = Space.Host.GetReference("thehingejoint").HingeJoint
OVC = function()
spring = hingejoint.Spring
spring.Damper = (slider.Value * 10.0) -- from 0.0 to 10.0
hingejoint.Spring = spring
end
slider.OnValueChanged(OVC)SpringTargetPosition = Space.Host.ExecutingObject.HingeJoint.Spring.TargetPosition--the below script will make a slider change a Hinge Joint Spring TargetPosition property
--[Add "theslider" and "thehingejoint" reference to the Scripting Runtime component]
slider = Space.Host.GetReference("theslider").UISlider
hingejoint = Space.Host.GetReference("thehingejoint").HingeJoint
OVC = function()
spring = hingejoint.Spring
spring.TargetPosition = (slider.Value * 10.0) -- from 0.0 to 10.0
hingejoint.Spring = spring
end
slider.OnValueChanged(OVC)-- Let's create a new layer mask to filter out other avatars, then overwrite it to be vehicles instead:
local mask = LayerMask.New({"Avatars"});
mask.SetLayers({"Vehicles"});
local hit = Space.Physics.RaycastSingle(Space.Host.ExecutingObject.WorldPosition, Space.Host.ExecutingObject.Forward, 500.0, mask)-- Let's create a new layer mask to filter out other avatars, then overwrite it to be vehicles instead:
local mask = LayerMask.New("Avatars");
mask.SetLayers("Vehicles");
local hit = Space.Physics.RaycastSingle(Space.Host.ExecutingObject.WorldPosition, Space.Host.ExecutingObject.Forward, 500.0, mask)local mask = LayerMask.New("Avatars");
mask.AddLayer("Vehicles");
local hit = Space.Physics.RaycastSingle(Space.Host.ExecutingObject.WorldPosition, Space.Host.ExecutingObject.Forward, 500.0, mask)local mask = LayerMask.New("Avatars");
mask.AddLayer("Vehicles");
local hit = Space.Physics.RaycastSingle(Space.Host.ExecutingObject.WorldPosition, Space.Host.ExecutingObject.Forward, 500.0, mask)local mask = LayerMask.New("Avatars", "Vehicles", "UI");
mask.RemoveLayer("Vehicles");
local hit = Space.Physics.RaycastSingle(Space.Host.ExecutingObject.WorldPosition, Space.Host.ExecutingObject.Forward, 500.0, mask)local mask = LayerMask.New("Avatars", "Vehicles", "UI");
mask.RemoveLayer("Vehicles");
local hit = Space.Physics.RaycastSingle(Space.Host.ExecutingObject.WorldPosition, Space.Host.ExecutingObject.Forward, 500.0, mask)local mask = LayerMask.New({"Avatars", "Vehicles"});
local hit = Space.Physics.RaycastSingle(Space.Host.ExecutingObject.WorldPosition, Space.Host.ExecutingObject.Forward, 500.0, mask)local mask = LayerMask.New("Avatars");
or
local mask = LayerMask.New("Avatars", "Vehicles", "UI");
local hit = Space.Physics.RaycastSingle(Space.Host.ExecutingObject.WorldPosition, Space.Host.ExecutingObject.Forward, 500.0, mask)local mask = LayerMask.New("Avatars");
-- Now change it to be an exclusionary mask that gets everything EXCEPT Avatars.'
mask.inverted = true;local mask = LayerMask.New("Avatars");
-- Get
local layers = mask.Layers;
-- Set
local layers = {"Vehicles", "UI"};
mask.Layers = layers;override string ToString ()
static SJointMotor New (float targetVelocity, float force, bool freeSpin)
float TargetVelocity get
float Force get
bool FreeSpin get
MotorString = Space.Host.ExecutingObject.HingeJoint.Motor.ToString()--the below script will make a UI Text element display this GameObjects Hinge Joint Motor properties
--[Add "thetext" and "thehingejoint" reference to the Scripting Runtime component]
thisObject = Space.Host.ExecutingObject
text = Space.Host.GetReference("thetext").UIText
hingejoint = Space.Host.GetReference("thehingejoint").HingeJoint
function OnUpdateFunction()
motor = hingejoint.Motor
text.Text = motor.ToString()
end
thisObject.OnUpdate(OnUpdateFunction)Motor= Space.Host.ExecutingObject.HingeJoint.Motor.New(1,2,true)--the below script will change all Hinge Joint Motor properties to 0 when clicked
--[Add "thehingejoint" reference to the Scripting Runtime component]
thisObject = Space.Host.ExecutingObject
hingejoint = Space.Host.GetReference("thehingejoint").HingeJoint
function OnClickFunction()
motor = hingejoint.Motor
hingejoint.Motor = motor.New(0,0,false)
end
thisObject.AddClickable()
thisObject.Clickable.OnClick(OnClickFunction)MotorTargetVelocity = Space.Host.ExecutingObject.HingeJoint.Motor.TargetVelocity--the below script will make a slider change a Hinge Joint Motor TargetVelocity property
--[Add "theslider" and "thehingejoint" reference to the Scripting Runtime component]
slider = Space.Host.GetReference("theslider").UISlider
hingejoint = Space.Host.GetReference("thehingejoint").HingeJoint
OVC = function()
motor = hingejoint.Motor
motor.TargetVelocity = (slider.Value * 10.0) -- from 0.0 to 10.0
hingejoint.Motor = motor
end
slider.OnValueChanged(OVC)MotorForce= Space.Host.ExecutingObject.HingeJoint.Motor.Force --the below script will make a slider change a Hinge Joint Motor Force property
--[Add "theslider" and "thehingejoint" reference to the Scripting Runtime component]
slider = Space.Host.GetReference("theslider").UISlider
hingejoint = Space.Host.GetReference("thehingejoint").HingeJoint
OVC = function()
motor = hingejoint.Motor
motor.Force = (slider.Value * 10.0) -- from 0.0 to 10.0
hingejoint.Motor = motor
end
slider.OnValueChanged(OVC)MotorFreeSpin = Space.Host.ExecutingObject.HingeJoint.Motor.FreeSpin--the below script will toggle Hinge Joint Motor FreeSpin property
--[Add "thehingejoint" reference to the Scripting Runtime component]
thisGameObject = Space.Host.ExecutingObject
hingejoint = Space.Host.GetReference("thehingejoint").HingeJoint
function OnClickFunction()
motor = hingejoint.Motor
motor.FreeSpin = not motor.FreeSpin
hingejoint.Motor = motor
end
thisGameObject.AddClickable()
thisGameObject.Clickable.OnClick(OnClickFunction)SSocialMedia[] get
string UserName get
string Title get
string RealName get
string Gender get
string Since get
string Country get
string City get
int SocialGold get
int SocialSilver get
int SocialFlower get
string Interests get
string get
int get
int get
string get
string get
string get
int get
int get
int get
int get
SLandmark[] get
SSubRegion[] get
int ID get
The Region ID of this region
int OwnerID get
The ID of the owner of this region
string Name get
The Name of this region
string MapPath get
Property Description
string PreviewPath get
Property Description
int RankingScore get
The Ranking Score of the region.
int MaxAvatars get
The max number of avatars this region can hold.
int FileSize get
The current MBs the region is using.
int Memory get
Property Description
SLandmark[] Landmarks get
An array of Landmarks in the region.
SSubRegion[] Regions get
Returns an array of SSubRegion in the region.
string Description get
Returns the description of the region.
int Access get
The access type of the region (such as "Public" or "Approved only") 1= Disabled, 2= FreeForall, 3= FriendsOnly, 4= ApprovedOnly, 5= GroupsOnly
static string MD5 (string input)
Calculates the MD5Sum of input and returns the result as a hexadecimal string
static string SHA1 (string input)
Function Description
static string Replace (string old, string pattern, string replace)
Function Description
static string GenerateGUID ()
Function Description
static string Base64Encode (string input)
Converts input to Base64 and returns the result
static string Base64Decode (string input)
Converts input from Base64 and returns the result
static byte[] GetBytes (string input)
Converts input to bytes using UTF8 encoding
static string GetString (byte[] bytes)
Converts input to a UTF8 string
static string EncodeURL (string input)
Function Description
static string DecodeURL (string input)
Function Description
static string RegexMatchResult (string input, string pattern, string replacement)
Function Description
override string ToString ()
Returns this SJointLimits's properties as a string
static SJointLimits New (float min, float max, float bounciness, float bounceMinVelocity, float contactDistance)
Creates a new SJoinLimits with the given min, max, bounciness, bounceMinVelocity and contactDistance.
float Min get set
The lower angular limit (in degrees) of the joint.
float Max get set
The upper angular limit (in degrees) of the joint.
float Bounciness get set
Determines the size of the bounce when the joint hits it's limit. Also known as restitution.
float BounceMinVelocity get set
The minimum impact velocity which will cause the joint to bounce.
float ContactDistance get set
Distance inside the limit value at which the limit will be considered to be active by the solver.
userName = Space.Profile.ActivePlayerProfile.UsernameuserTitle = Space.Profile.ActivePlayerProfile.TitleuserRealName = Space.Profile.ActivePlayerProfile.RealNameuserGender = Space.Profile.ActivePlayerProfile.GenderuserSince = Space.Profile.ActivePlayerProfile.SinceuserCountry = Space.Profile.ActivePlayerProfile.CountryuserCity = Space.Profile.ActivePlayerProfile.CityuserSocialGold = Space.Profile.ActivePlayerProfile.SocialGolduserSocialSilver = Space.Profile.ActivePlayerProfile.SocialSilveruserSocialFlower = Space.Profile.ActivePlayerProfile.SocialFloweruserInterests = Space.Profile.ActivePlayerProfile.InterestsuserAbout = Space.Profile.ActivePlayerProfile.AbouttableOfSSocialMedia = Space.Profile.ActivePlayerProfile.SocialMediaProfilesfunction GetUserRegionsComplete(SUserRegions)
local r = SUserRegions.AvailableRegions[1]
regionID = r.ID
end
Space.Grid.GetEnabledUserRegions(GetUserRegionsComplete)function GetUserRegionsComplete(SUserRegions)
local r = SUserRegions.AvailableRegions[1]
regionOwnerID = r.OwnerID
end
Space.Grid.GetEnabledUserRegions(GetUserRegionsComplete)function GetUserRegionsComplete(SUserRegions)
local r = SUserRegions.AvailableRegions[1]
regionName = r.Name
end
Space.Grid.GetEnabledUserRegions(GetUserRegionsComplete)function GetUserRegionsComplete(SUserRegions)
local r = SUserRegions.AvailableRegions[1]
regionMapPath = r.MapPath
end
Space.Grid.GetEnabledUserRegions(GetUserRegionsComplete)--Make's a UIText show the Preview Path of the user's first available region
textObject = Space.Host.GetReference("TheTextReference")
function GetUserRegionsComplete(SUserRegions)
local r = SUserRegions.AvailableRegions[1]
regionPreviewPath = r.PreviewPath
end
Space.Grid.GetEnabledUserRegions(GetUserRegionsComplete)function GetUserRegionsComplete(SUserRegions)
local r = SUserRegions.AvailableRegions[1]
regionRankingScore = r.RankingScore
end
Space.Grid.GetEnabledUserRegions(GetUserRegionsComplete)function GetUserRegionsComplete(SUserRegions)
local r = SUserRegions.AvailableRegions[1]
regionMaxAvatars = r.MaxAvatars
end
Space.Grid.GetEnabledUserRegions(GetUserRegionsComplete)function GetUserRegionsComplete(SUserRegions)
local r = SUserRegions.AvailableRegions[1]
regionFileSize = r.FileSize
end
Space.Grid.GetEnabledUserRegions(GetUserRegionsComplete)function GetUserRegionsComplete(SUserRegions)
local r = SUserRegions.AvailableRegions[1]
regionMemory = r.Memory
end
Space.Grid.GetEnabledUserRegions(GetUserRegionsComplete)function GetUserRegionsComplete(SUserRegions)
local r = SUserRegions.AvailableRegions[1]
regionLandmarks = r.Landmarks
end
Space.Grid.GetEnabledUserRegions(GetUserRegionsComplete)function GetUserRegionsComplete(SUserRegions)
local r = SUserRegions.AvailableRegions[1]
regionSubRegions = r.Regions
end
Space.Grid.GetEnabledUserRegions(GetUserRegionsComplete)function GetUserRegionsComplete(SUserRegions)
local r = SUserRegions.AvailableRegions[1]
regionDescription = r.Description
end
Space.Grid.GetEnabledUserRegions(GetUserRegionsComplete)function GetUserRegionsComplete(SUserRegions)
local r = SUserRegions.AvailableRegions[1]
regionAccessType = r.Access
end
Space.Grid.GetEnabledUserRegions(GetUserRegionsComplete)string Description get
SAccessType Access get
static string MD5 (string input)
static string SHA1 (string input)
static string Replace (string old, string pattern, string replace)
static string GenerateGUID ()
static string Base64Encode (string input) static string Base64Encode (byte[] input)
static string Base64Decode (string input)
static byte[] GetBytes (string input)
static string GetString (byte[] bytes)
static string EncodeURL (string input)
static string DecodeURL (string input)
static string RegexMatchResult (string input, string pattern, string replacement)
override string ToString ()
static SJointLimits New (float min, float max, float bounciness, float bounceMinVelocity, float contactDistance)
float Min get set
float Max get set
float Bounciness get set
float BounceMinVelocity get set
float ContactDistance get set
md5 = Space.String.MD5('AString')sha1 = Space.String.SHA1('AString')replaced = Space.String.Replace('AString', 'APattern', 'AReplace')guid = Space.String.GenerateGUID()baseEncodeByte = Space.String.Base64Encode{117, 116, 32, 116, 100, 101})baseDecodedStr = Space.String.Base64Decode('aW5wdXQgdG8gZW5jb2Rl')stringAsByteArray = Space.String.GetBytes('A String')ByteArrayAsString = Space.String.GetString({115, 111, 109, 101, 32})encodedURL = Space.String.EncodeURL('A String')decodedURL = Space.String.DecodeURL('A String')Space.Math.RegexMatchResult('astring', 'astring','astring')LimitsString = Space.Host.ExecutingObject.HingeJoint.Limits.ToString()--the below script will make a UI Text element display this GameObjects Hinge Joint Limits' properties
--[Add "thetext" and "thehingejoint" reference to the Scripting Runtime component]
thisObject = Space.Host.ExecutingObject
text = Space.Host.GetReference("thetext").UIText
hingejoint = Space.Host.GetReference("thehingejoint").HingeJoint
function OnUpdateFunction()
limits = hingejoint.Limits
text.Text = limits.ToString()
end
thisObject.OnUpdate(OnUpdateFunction)Limits = Space.Host.ExecutingObject.HingeJoint.Limits.New((1,2,3,4,5))--the below script will change all Hinge Joint Limits properties to 0 when clicked
--[Add "thehingejoint" reference to the Scripting Runtime component]
thisObject = Space.Host.ExecutingObject
hingejoint = Space.Host.GetReference("thehingejoint").HingeJoint
function OnClickFunction()
limits = hingejoint.Limits
hingejoint.Limits = limits.New(0,0,0,0,0)
end
thisObject.AddClickable()
thisObject.Clickable.OnClick(OnClickFunction)LimitsMin = Space.Host.ExecutingObject.HingeJoint.Limits.Min--the below script will make a slider change a Hinge Joint Limits Min property
--[Add "theslider" and "thehingejoint" reference to the Scripting Runtime component]
slider = Space.Host.GetReference("theslider").UISlider
hingejoint = Space.Host.GetReference("thehingejoint").HingeJoint
OVC = function()
limits = hingejoint.Limits
limits.Min = (slider.Value * 10.0) -- from 0.0 to 10.0
hingejoint.Limits = limits
end
slider.OnValueChanged(OVC)LimitsMax= Space.Host.ExecutingObject.HingeJoint.Limits.Max --the below script will make a slider change a Hinge Joint Limits Max property
--[Add "theslider" and "thehingejoint" reference to the Scripting Runtime component]
slider = Space.Host.GetReference("theslider").UISlider
hingejoint = Space.Host.GetReference("thehingejoint").HingeJoint
OVC = function()
limits = hingejoint.Limits
limits.Max = (slider.Value * 10.0) -- from 0.0 to 10.0
hingejoint.Limits = limits
end
slider.OnValueChanged(OVC)LimitsBounciness = Space.Host.ExecutingObject.HingeJoint.Limits.Bounciness --the below script will make a slider change a Hinge Joint Limits Bounciness property
--[Add "theslider" and "thehingejoint" reference to the Scripting Runtime component]
slider = Space.Host.GetReference("theslider").UISlider
hingejoint = Space.Host.GetReference("thehingejoint").HingeJoint
OVC = function()
limits = hingejoint.Limits
limits.Bounciness = (slider.Value * 1.0) -- from 0.0 to 1.0
hingejoint.Limits = limits
end
slider.OnValueChanged(OVC) LimitsBounceMinVelocity = Space.Host.ExecutingObject.HingeJoint.Limits.BounceMinVelocity--the below script will make a slider change a Hinge Joint Limits BounceMinVelocity property
--[Add "theslider" and "thehingejoint" reference to the Scripting Runtime component]
slider = Space.Host.GetReference("theslider").UISlider
hingejoint = Space.Host.GetReference("thehingejoint").HingeJoint
OVC = function()
limits = hingejoint.Limits
limits.BounceMinVelocity = (slider.Value * 10.0) -- from 0.0 to 10.0
hingejoint.Limits = limits
end
slider.OnValueChanged(OVC)LimitsContactDistance = Space.Host.ExecutingObject.HingeJoint.Limits.ContactDistance--the below script will make a slider change a Hinge Joint Limits Contact Distance property
--[Add "theslider" and "thehingejoint" reference to the Scripting Runtime component]
slider = Space.Host.GetReference("theslider").UISlider
hingejoint = Space.Host.GetReference("thehingejoint").HingeJoint
OVC = function()
limits = hingejoint.Limits
limits.ContactDistance = (slider.Value * 10.0) -- from 0.0 to 10.0
hingejoint.Limits = limits
end
slider.OnValueChanged(OVC)int get
int get
string get
string get
string get
string get
int get
string get
string get
int ID get
The ID of the group.
int OwnerID get
The ID of the group's owner.
string Name get
The name of the group.
string Description get
The description of the group.
string Access get
The level of access the group has, e.g. public or private.
string ImageUrl get
The URL of the group's image.
int MaxAvatars get
The max number of members the group can have.
string Role get
Player's role in this group.
string CreateDate get
Creation date of the group.
string ()
SColor (SColor b, float t)
bool (SColor other)
override string ()
static SColor (float r, float g, float b, float a)
static SColor (string hex)
float get
float get
float get
float get
SColor get
SColor get
SColor get
SColor get
SColor get
string ToHex ()
Return the Hex value of the color.
Linearly interpolates between current color and b by t.
bool Equals (SColor other)
Returns true if colors are same.
string ToString ()
Returns the RGBA value of the current color.
static SColor New (float r, float g, float b, float a)
Create a color by red, green, blue and alpha parameters.
static SColor FromHex (string hex)
Create a color by Hex value.
float R get
Property Description
float G get
Property Description
float B get
Property Description
float A get
Property Description
SColor Black get
Solid black. RGBA is (0, 0, 0, 1).
SColor White get
Solid White. RGBA is (1, 1, 1, 1).
SColor Red get
Solid Red. RGBA is (1, 0, 0, 1).
SColor Blue get
Solid Blue. RGBA is (0, 0, 1, 1).
SColor Green get
Solid Green. RGBA is (0, 1, 0, 1).
SColor Yellow get
Yellow. RGBA is (1, 0.92, 0.016, 1).
ID = Space.Groups.GetGroupInfo(350).IDOwnerID = Space.Groups.GetGroupInfo(350).OwnerID--Clicking this object will show canvas1 if you are a group's owner
--and will show canvas2 if you are not
thisObject = Space.Host.ExecutingObject
canvas1 = Space.Host.GetReference("canvas1")--Add this object with canvas as reference in Scripting Runtime
canvas2 = Space.Host.GetReference("canvas2")--Add this object with canvas as reference in Scripting Runtime
OnClickFunction = function()
local groupInfo = Space.Groups.GetGroupInfo(350)
if groupInfo.OwnerID == Space.Scene.PlayerAvatar.ID then
canvas1.Active = true
else
canvas2.Active = true
end
endName = Space.Groups.GetGroupInfo(350).Name--Clicking this object will show group 355's Name on a UIText object
thisObject = Space.Host.ExecutingObject
uiText = Space.Host.GetReference("text").UIText --Add this object with UIText component as reference in Scripting Runtime
OnClickFunction = function()
GroupInfo = Space.Groups.GetGroupInfo(350)
uiText.Text = GroupInfo.Name
end
thisObject.AddClickable()
thisObject.Clickable.OnClick(OnClickFunction)Description =Space.Groups.GetGroupInfo(350).Description--Clicking this object will show group 355's Description on a UIText object
thisObject = Space.Host.ExecutingObject
uiText = Space.Host.GetReference("text").UIText --Add this object with UIText component as reference in Scripting Runtime
OnClickFunction = function()
GroupInfo = Space.Groups.GetGroupInfo(350)
uiText.Text = GroupInfo.Description
end
thisObject.AddClickable()
thisObject.Clickable.OnClick(OnClickFunction)Access = Space.Groups.GetGroupInfo(350).Access--Clicking this object will show group 355's Access on a UIText object
thisObject = Space.Host.ExecutingObject
uiText = Space.Host.GetReference("text").UIText --Add this object with UIText component as reference in Scripting Runtime
OnClickFunction = function()
GroupInfo = Space.Groups.GetGroupInfo(350)
uiText.Text = GroupInfo.Access
end
thisObject.AddClickable()
thisObject.Clickable.OnClick(OnClickFunction)ImageUrl = Space.Groups.GetGroupInfo(350).ImageUrl--Clicking this object will show group 355's ImageUrl on a UIText object
thisObject = Space.Host.ExecutingObject
uiText = Space.Host.GetReference("text").UIText --Add this object with UIText component as reference in Scripting Runtime
OnClickFunction = function()
GroupInfo = Space.Groups.GetGroupInfo(350)
uiText.Text = GroupInfo.ImageUrl
end
thisObject.AddClickable()
thisObject.Clickable.OnClick(OnClickFunction)MaxAvatars = Space.Groups.GetGroupInfo(350).MaxAvatars--Clicking this object will show group 355's MaxAvatars on a UIText object
thisObject = Space.Host.ExecutingObject
uiText = Space.Host.GetReference("text").UIText --Add this object with UIText component as reference in Scripting Runtime
OnClickFunction = function()
GroupInfo = Space.Groups.GetGroupInfo(350)
uiText.Text = GroupInfo.MaxAvatars
end
thisObject.AddClickable()
thisObject.Clickable.OnClick(OnClickFunction)Role = Space.Groups.GetGroupInfo(350).Role--Clicking this object will show canvas1 if you are a VIP in the group
--and will show canvas2 if you are a regular member
--and will show canvas3 if you are the group owner
thisObject = Space.Host.ExecutingObject
canvas1 = Space.Host.GetReference("canvas1")--Add this object with canvas as reference in Scripting Runtime
canvas2 = Space.Host.GetReference("canvas2")--Add this object with canvas as reference in Scripting Runtime
canvas3 = Space.Host.GetReference("canvas3")--Add this object with canvas as reference in Scripting Runtime
OnClickFunction = function()
local groupInfo = Space.Groups.GetGroupInfo(350)
if groupInfo.Role == "Owner" then
canvas3.Active = true
elseif groupInfo.Role == "VIP" then
canvas1.Active = true
elseif groupInfo.Role == "Normal" then
canvas2.Active = true
end
endCreateDate = Space.Groups.GetGroupInfo(350).CreateDate--Clicking this object will show group 355's creation date on a UIText object
thisObject = Space.Host.ExecutingObject
uiText = Space.Host.GetReference("text").UIText --Add this object with UIText component as reference in Scripting Runtime
OnClickFunction = function()
CreateDate = Space.Groups.GetGroupInfo(350).CreateDate
uiText.Text = CreateDate
end
thisObject.AddClickable()
thisObject.Clickable.OnClick(OnClickFunction)colorRedHex = Color.Red.ToHex()lerpedRedBlue = Color.Blue.Lerp(Color.Red, 0.5)--create a cube and set a new material.
--add ScriptingRuntime.
local mat=Space.Host.ExecutingObject.Renderer.Material
function ChangeColor()
mat.SetColor("_Color",Color.Red.Lerp(Color.Blue,Space.Math.PingPong(Space.Time,1)))
end
Space.Host.ExecutingObject.OnUpdate(ChangeColor)isItTrue = Color.Red.Equals(Color.Blue)redString = Color.Red.ToString()theColor = Color.New(255.0, 0.0, 0.0, 1.0)fromHex = Color.FromHex('FF0000')r = Color.Red.Rg = Color.Red.Gg = Color.Red.Bg = Color.Red.AblackColor = Color.BlackwhiteColor = Color.WhiteblackRed = Color.RedblueColor = Color.BluegreenColor = Color.Green
yellowColor = Color.YellowSColor Yellow get
void LoadOutfit (int outfitID)
Changes the current Avatar's outfit to outfitID. For a player Avatar, this only works on white-label grid. For NPC avatars, this works on all grids.
void ResetOutfit ()
Changes the current Avatar's outfit and resets it to outfitID 0. For a player Avatar, this only works on white-label grid. For NPC avatars, this works on all grids.
void ResetOutfitToTemplate (int outfitID)
Changes the current Avatar's outfit to outfitID only if the player running this code already owns that outfit. For a player Avatar, this only works on white-label grid. For NPC avatars, this works on all grids.
float GetSlider (int slider)
Return the value of Appearance Sliders.
float GetHeight ()
Return height of avatar.
GetSkinTone ()
Return skin tone of avatar.
GetEyeTone ()
Return eye tone of avatar.
long OutfitID get
Return the current outfit id.
Skeleton get
Return the GameObject of avatar skeleton.
bool Loaded get
Returns true if the avatar is full loaded.
GameObject get
Property Description
position get set
The position of the particle.
velocity get set
The velocity of the particle.
animatedVelocity get
The animated velocity of the particle.
totalVelocity get
The total velocity of the particle.
float remainingLifetime get set
The remaining lifetime of the particle.
float startLifetime get set
The starting lifetime of the particle.
startColor get set
The initial color of the particle. The current color of the particle is calculated procedurally based on this value and the active color modules.
uint randomSeed get set
The random seed of the particle.
axisOfRotation get set
Mesh particles rotate around this axis.
float startSize get set
The initial size of the particle. The current size of the particle is calculated procedurally based on this value and the active size modules.
startSize3D get set
The initial 3D size of the particle. The current size of the particle is calculated procedurally based on this value and the active size modules.
float rotation get set
The rotation of the particle.
rotation3D get set
The 3D rotation of the particle.
this = Space.Host.ExecutingObject
OnParticleTrigger = function(GameObject) ParticlesArray = this.ParticleSystem.GetTriggerParticles(0) FirstParticle = ParticlesArray[1] rotation3D= FirstParticle.rotation3D
end
this.SubscribeToEvents() this.OnParticleTrigger(OnParticleTrigger)
float angularVelocity get set
The angular velocity of the particle.
angularVelocity3D get set
The 3D angular velocity of the particle.
void LoadOutfit (int outfitID)
void ResetOutfit ()
void ResetOutfitToTemplate (int outfitID)
float GetSlider (SAppearanceSlider slider)
float GetHeight ()
SColor GetSkinTone ()
SColor GetEyeTone ()
long OutfitID get
SGameObject Skeleton get
bool Loaded get
SGameObject GameObject get
slider
int
1= Asian, 2= European, 3= African, 4= FaceShape, 5= FaceWidth, 6= FaceLength, 7= ForeheadShape, 8= ForeheadDepth, 9= CheekHeight, 10= CheekWidth, 11= JawShape, 12= JawWidth, 13= JawHeight, 14= EyebrowHeight, 15= EyebrowDepth, 16= EyeHeight, 17= EyeSpacing, 18= EyeSize, 19= EyeWidth, 20= EyeballSize, 21= EyeInside, 22= EyeOutside, 23= EyelashLength, 24= NoseWidth, 25= NoseDepth, 26= NoseHeight, 27= NoseShape, 28= NoseTipShape, 29= NostrilWidth, 30= MouthWidth, 31= MouthHeight, 32= MouthDepth, 33= UpperLipWidth, 34= UpperLipThickness, 35= LowerLipWidth, 36= LowerLipThickness, 37= Smile, 38= EarHeight, 39= EarWidth, 40= Earlobe, 41= EarShape, 42= Muscular, 43= Toned, 44= Grand, 45= Lean, 46= SkullHeight, 47= SkullWidth, 48= SkullDepth, 49= NeckThickness, 50= ShoulderThickness, 51= UpperArmThickness, 52= ForearmThickness, 53= WristSize, 54= ElbowThin, 55= HandThickness, 56= HandTone, 57= FingerWidth, 58= BustProximity, 59= BustSize, 60= ChestDepth, 61= PectoralSize, 62= PectoralHeight, 63= AbdomenMiddle, 64= AbdomenDepth, 65= WaistWidth, 66= HipSize, 67= GlutesSize, 68= GlutesHeight, 69= LoveHandles, 70= ThighSize, 71= KneeTone, 72= ShinSize, 73= AnkleTone, 74= FootThickness, 75= FootTone, 76= ToeWidth, 77= HeadSize, 78= NeckSize, 79= ShoulderSize, 80= UpperArmSize, 81= ForearmSize, 82= HandSize, 83= SpineSize, 84= ChestSize, 85= UpperLegSize, 86= LowerLegSize, 87= FeetSize, 88= ToesSize, 89= HeadPosition, 90= NeckLength, 91= ForearmLength, 92= HandPosition, 93= SpineLength, 94= ChestLength, 95= UpperLegLength, 96= LowerLegLength, 97= FeetLength, 98= ToesLength, 99= ShoulderHeight, 100= ShoulderWidth, 101= FeetFloorOffset
Space.Host.ExecutingObject.AvatarAppearance.LoadOutfit(160)--this script toggles between 3 different outfits when NPC Statue object is clicked
--[Object needs to have an NPC Statue component]
outfits = {4134388, 4134385, 4134386}
currentOutfit = 0
thisObject = Space.Host.ExecutingObject
function OnClickFunction()
if currentOutfit == #outfits then
currentOutfit = 1
else
currentOutfit = currentOutfit + 1
end
thisObject.AvatarAppearance.LoadOutfit(outfits[currentOutfit])
end
thisObject.AddClickable()
thisObject.Clickable.OnClick(OnClickFunction)Space.Host.ExecutingObject.AvatarAppearance.ResetOutfit()--this script makes a UIButton reset an NPC statue outfit when clicked
--[UIButton object needs to be linked in scripting runtime references with name "button1"]
--[Object needs to have an NPC Statue component]
thisObject = Space.Host.ExecutingObject
refButton = Space.Host.GetReference("button1")
function OnClickFunction()
thisObject.AvatarAppearance.ResetOutfit()
end
refButton.UIButton.OnClick(OnClickFunction)Space.Host.ExecutingObject.AvatarAppearance.ResetOutfitToTemplate(10001)--this script toggles between 3 different outfits when NPC Statue object is clicked
--[Object needs to have an NPC Statue component]
--For this function, the player needs to own this outfit. Use LoadOutfit if player might not own it
outfits = {4134388, 4134385, 4134386}
currentOutfit = 0
thisObject = Space.Host.ExecutingObject
function OnClickFunction()
if currentOutfit == #outfits then
currentOutfit = 1
else
currentOutfit = currentOutfit + 1
end
thisObject.AvatarAppearance.ResetOutfitToTemplate(outfits[currentOutfit])
end
thisObject.AddClickable()
thisObject.Clickable.OnClick(OnClickFunction)FaceLength = Space.Host.ExecutingObject.AvatarAppearance.GetSlider(AppearanceSlider.FaceLength)--this script updates a UIText with the current Face Length of the npc
thisObject = Space.Host.ExecutingObject
uiText = Space.Host.GetReference("thetext").UIText --Add this object with UIText component as reference in Scripting Runtime
OnUpdateFunction = function()
uiText.Text = thisObject.AvatarAppearance.GetSlider(AppearanceSlider.FaceLength)
end
thisObject.OnUpdate(OnUpdateFunction)height = Space.Host.ExecutingObject.AvatarAppearance.GetHeight()--this script updates a UIText with the height of this NPC statue
thisObject = Space.Host.ExecutingObject
uiText = Space.Host.GetReference("thetext").UIText --Add this object with UIText component as reference in Scripting Runtime
OnUpdateFunction = function()
uiText.Text = thisObject.AvatarAppearance.GetHeight()
end
thisObject.OnUpdate(OnUpdateFunction)SkinTone = Space.Host.ExecutingObject.AvatarAppearance.GetSkinTone()--this script updates a UIText with the current Skin Tone of the npc
thisObject = Space.Host.ExecutingObject
uiText = Space.Host.GetReference("thetext").UIText --Add this object with UIText component as reference in Scripting Runtime
OnUpdateFunction = function()
uiText.Text = thisObject.AvatarAppearance.GetSkinTone().ToString()
end
thisObject.OnUpdate(OnUpdateFunction) EyeTone = Space.Host.ExecutingObject.AvatarAppearance.GetEyeTone()--this script updates a UIText with the current Eye Tone of the npc
thisObject = Space.Host.ExecutingObject
uiText = Space.Host.GetReference("thetext").UIText --Add this object with UIText component as reference in Scripting Runtime
OnUpdateFunction = function()
uiText.Text = thisObject.AvatarAppearance.GetEyeTone().ToString()
end
thisObject.OnUpdate(OnUpdateFunction)outfitID= Space.Host.ExecutingObject.AvatarAppearance.OutfitID--this script updates a UIText with the current outfit ID of the npc
thisObject = Space.Host.ExecutingObject
uiText = Space.Host.GetReference("thetext").UIText --Add this object with UIText component as reference in Scripting Runtime
OnUpdateFunction = function()
uiText.Text = thisObject.GameObject.AvatarAppearance.OutfitID
end
thisObject.OnUpdate(OnUpdateFunction)playerSkeleton = Space.Host.ExecutingObject.AvatarAppearance.SkeletonisLoaded= Space.Host.ExecutingObject.AvatarAppearance.Loaded--this script updates a UIText with the loading status of the npc
thisObject = Space.Host.ExecutingObject
uiText = Space.Host.GetReference("thetext").UIText --Add this object with UIText component as reference in Scripting Runtime
OnUpdateFunction = function()
uiText.Text = thisObject.AvatarAppearance.Loaded
end
thisObject.OnUpdate(OnUpdateFunction) npcGameObject = Space.Host.ExecutingObject.AvatarAppearance.GameObjectSVector get set
float get set
SVector get set
SVector position get set
SVector velocity get set
SVector animatedVelocity get
SVector totalVelocity get
float remainingLifetime get set
float startLifetime get set
SColor startColor get set
uint randomSeed get set
SVector axisOfRotation get set
float startSize get set
SVector startSize3D get set
float get set
void Clear ()
Reset all the parameters of this RaycastResult
string ToString ()
Converts all the properties of this UIRaycastResult into a string
float Distance get
Returns the distance of the Raycast result
float Index get
Returns the Index of the Raycast result
int Depth get
Returns the Depth of the Raycast result
int SortingLayer get
Returns the Sorting Layer of the Raycast result
int SortingOrder get
Returns the Sorting Order of the Raycast result
WorldPosition get
Returns the World Position vector of the Raycast result
WorldNormal get
Returns the World Normal vector of the Raycast result
ScreenPosition get
Returns the Screen Position vector of the Raycast result
GameObject get
Returns a reference to the GameObject of the Raycast result
bool IsValid get
Returns whether the Raycast hit a valid UI Raycast target. This will be true if the Raycast hits an element on Sinespace's UI
this = Space.Host.ExecutingObject
OnParticleTrigger = function(GameObject)
ParticlesArray = this.ParticleSystem.GetTriggerParticles(0)
FirstParticle = ParticlesArray[1]
position = FirstParticle.position
end
this.SubscribeToEvents()
this.OnParticleTrigger(OnParticleTrigger)example 2this = Space.Host.ExecutingObject
OnParticleTrigger = function(GameObject)
ParticlesArray = this.ParticleSystem.GetTriggerParticles(0)
FirstParticle = ParticlesArray[1]
velocity= FirstParticle.velocity
end
this.SubscribeToEvents()
this.OnParticleTrigger(OnParticleTrigger)this = Space.Host.ExecutingObject
OnParticleTrigger = function(GameObject)
ParticlesArray = this.ParticleSystem.GetTriggerParticles(0)
FirstParticle = ParticlesArray[1]
animatedVelocity= FirstParticle.animatedVelocity
end
this.SubscribeToEvents()
this.OnParticleTrigger(OnParticleTrigger)example 2this = Space.Host.ExecutingObject
OnParticleTrigger = function(GameObject)
ParticlesArray = this.ParticleSystem.GetTriggerParticles(0)
FirstParticle = ParticlesArray[1]
totalVelocity= FirstParticle.totalVelocity
end
this.SubscribeToEvents()
this.OnParticleTrigger(OnParticleTrigger)this = Space.Host.ExecutingObject
OnParticleTrigger = function(GameObject)
ParticlesArray = this.ParticleSystem.GetTriggerParticles(0)
FirstParticle = ParticlesArray[1]
remainingLifetime= FirstParticle.remainingLifetime
end
this.SubscribeToEvents()
this.OnParticleTrigger(OnParticleTrigger)this = Space.Host.ExecutingObject
OnParticleTrigger = function(GameObject)
ParticlesArray = this.ParticleSystem.GetTriggerParticles(0)
FirstParticle = ParticlesArray[1]
startLifetime= FirstParticle.startLifetime
end
this.SubscribeToEvents()
this.OnParticleTrigger(OnParticleTrigger)this = Space.Host.ExecutingObject
OnParticleTrigger = function(GameObject)
ParticlesArray = this.ParticleSystem.GetTriggerParticles(0)
FirstParticle = ParticlesArray[1]
startColor= FirstParticle.startColor
end
this.SubscribeToEvents()
this.OnParticleTrigger(OnParticleTrigger)this = Space.Host.ExecutingObject
OnParticleTrigger = function(GameObject)
ParticlesArray = this.ParticleSystem.GetTriggerParticles(0)
FirstParticle = ParticlesArray[1]
randomSeed= FirstParticle.randomSeed
end
this.SubscribeToEvents()
this.OnParticleTrigger(OnParticleTrigger)this = Space.Host.ExecutingObject
OnParticleTrigger = function(GameObject)
ParticlesArray = this.ParticleSystem.GetTriggerParticles(0)
FirstParticle = ParticlesArray[1]
axisOfRotation= FirstParticle.axisOfRotation
end
this.SubscribeToEvents()
this.OnParticleTrigger(OnParticleTrigger)this = Space.Host.ExecutingObject
OnParticleTrigger = function(GameObject)
ParticlesArray = this.ParticleSystem.GetTriggerParticles(0)
FirstParticle = ParticlesArray[1]
startSize= FirstParticle.startSize
end
this.OnParticleTrigger(OnParticleTrigger)this = Space.Host.ExecutingObject
OnParticleTrigger = function(GameObject)
ParticlesArray = this.ParticleSystem.GetTriggerParticles(0)
FirstParticle = ParticlesArray[1]
startSize3D= FirstParticle.startSize3D
end
this.OnParticleTrigger(OnParticleTrigger)this = Space.Host.ExecutingObject
OnParticleTrigger = function(GameObject)
ParticlesArray = this.ParticleSystem.GetTriggerParticles(0)
FirstParticle = ParticlesArray[1]
rotation= FirstParticle.rotation
end
this.OnParticleTrigger(OnParticleTrigger)</div>
</div>
<div data-gb-custom-block data-tag="tabs">
<div data-gb-custom-block data-tag="tab" data-title='Lua'>
```lua
example 2this = Space.Host.ExecutingObject
OnParticleTrigger = function(GameObject)
ParticlesArray = this.ParticleSystem.GetTriggerParticles(0)
FirstParticle = ParticlesArray[1]
angularVelocity= FirstParticle.angularVelocity
end
this.SubscribeToEvents()
this.OnParticleTrigger(OnParticleTrigger)this = Space.Host.ExecutingObject
OnParticleTrigger = function(GameObject)
ParticlesArray = this.ParticleSystem.GetTriggerParticles(0)
FirstParticle = ParticlesArray[1]
angularVelocity3D= FirstParticle.angularVelocity3D
end
this.SubscribeToEvents()
this.OnParticleTrigger(OnParticleTrigger)SMaterial Instantiate()
void (string key, float value)
float (string key)
void (string key, SColor color) void (string key, float r, float g, float b, float a)
(string key)
void (string key, byte r, byte g, byte b, byte a)
void (string key, int value)
int (string key)
void (string key, SResource value)
SResource (string key)
void (string key, float x, float y)
string get set
string get
int get set
SMaterial Instantiate()
Return a new SMaterial from old.
void SetFloat (string key, float value)
Sets a shader property to value
float GetFloat (string key)
Gets the current value of a shader property.
void SetColor (string key, SColor color) void SetColor (string key, float r, float g, float b, float a)
Sets a shader colour
SColor GetColor (string propertyName)
Get a named color value. Many shaders use more than one color. Use GetColor to get the propertyName color.
propertyName
string
Common color names used by Unity's builtin shaders: "_Color" is the main color of a material.
"_SpecColor" is the specular color of a material (used in specular/glossy/vertexlit shaders).
"_EmissionColor" is the emissive color of a material (used in vertexlit shaders). "_ReflectColor" is the reflection color of the material (used in reflective shaders).
void SetColor32 (string key, byte r, byte g, byte b, byte a)
Sets a shader colour to value (32-bit, 0..255 values)
void SetInt (string key, int value)
Sets a shader property to value. This can be a convenient way to work with Boolean values.
int GetInt (string key)
Gets the current value of a shader property. This can be a convenient way to work with Boolean values.
void SetTexture (string key, SResource value)
Sets a object's specified texture map (specified in parameter 1) to the texture provided as a resource in parameter #2. The example script must be in a object with a '_MainTex' map, and that object should be set as a resource on the scripting runtime. Additionally, that object should be called 'dispobj'.
note also that this function can be used to set any of the texture maps by varying the value of the first parameter accordingly.
SResource GetTexture (string propertyName)
Get a named texture. Many shaders use more than one texture. Use GetTexture to get the propertyName texture.
propertyName
string
Common texture names used by Unity's builtin shaders:
"_MainTex" is the main diffuse texture.
"_BumpMap" is the normal map. "_Cube" is the reflection cubemap.
void SetTextureOffset (string key, float x, float y)
Sets a texture offset to a value.
void SetTextureScale (string key, float x, float y)
Sets a texture scale to a value.
void SetVector (string key, SVector value)
Sets a shader property to value
string Name get set
Return a new SMaterial from old.
string Shader get
Return the shader name of current SMaterial.
int RenderQueue get set
Render queue of this material.
By default materials use render queue of the shader it uses. You can override the render queue used using this variable. Note that if a shader on the material is changed, the render queue resets to that of the shader itself.
Render queue value should be in [0..5000] range to work properly; or -1 to use the render queue from the shader.
void Clear ()
string ToString ()
float Distance get
float Index get
int Depth get
int SortingLayer get
int SortingOrder get
SVector WorldPosition get
SVector WorldNormal get
SVector ScreenPosition get
SGameObject GameObject get
bool get
local cube=Space.Host.ExecutingObject
local cube2=cube.Children[1]
local mat1=cube.Renderer.Material
local newMat=mat1.Instantiate() newMat.SetColor("_Color",Color.Red) cube2.Renderer.Material=newMat
--at this moment, cube2 will turn to red but cube will keep original color.-- Let's set the Metallic property to 0.75:
local obj = Space.Host.ExecutingObject;
obj.Renderer.Material.SetFloat("_Metallic", 0.75);-- Let's find out the current Glosiness level
local obj = Space.Host.ExecutingObject;
Space.Log(obj.Renderer.Material.GetFloat("_Glossiness"));
-- prints "0.5" (by default) to the console.-- Let's change the Color to red:
local obj = Space.Host.ExecutingObject;
local newColor = Color.New(1, 0, 0, 1);
obj.Renderer.Material.SetColor("_Color", newColor);-- Let's change the Color to purple:
local obj = Space.Host.ExecutingObject;
obj.Renderer.Material.SetColor("_Color", 0.5,0,0.5,1);Space.Host.ExecutingObject.Renderer.Material.GetColor("_Color")-- Let's change the Color to light blue:
local obj = Space.Host.ExecutingObject;
obj.Renderer.Material.SetColor32("_Color", 53,172,232,255);-- For example, let's disable Specular Highlights (enabled by default in the Standard shader):
local obj = Space.Host.ExecutingObject;
obj.Renderer.Material.SetInt("_SpecularHighlights", 0);-- Let's find out if the Reflections property is enabled:
local obj = Space.Host.ExecutingObject;
Space.Log(obj.Renderer.Material.GetInt("_GlossyReflections"));
-- prints "1" (by default) to the console, which means that the Reflections property is indeed enabled.function hithere()
image = "mrlee.jpg"
server = "https://middleware.systems/"
obj = Space.Host.GetReference("dispobj")
resrc = Space.WebServices.GetImage(server .. image)
obj.Renderer.Material.SetTexture("_MainTex", resrc)
endtextureResource = Space.Host.ExecutingObject.Renderer.Material.GetTexture("_MainTex")Space.Host.ExecutingObject.Renderer.Material.SetTextureOffset("_MainTex", 0, 1)Space.Host.ExecutingObject.Renderer.Material.SetTextureScale("_MainTex", 0, 1)Space.Host.ExecutingObject.Renderer.Material.SetTexture("_APropertyName", Vector.New(0,1,0))local cube=Space.Host.ExecutingObject
local mat=cube.Renderer.Material
Space.Log(mat.Name)local cube=Space.Host.ExecutingObject
local mat=cube.Renderer.Material
Space.Log(mat.Shader)RenderQueue = Space.Host.ExecutingObject.Renderer.Material.RenderQueueResult = Space.UI.Raycast()
Result.Clear()Result = Space.UI.Raycast().ToString()--This script will update a UIText element with the result of a UIRaycast whenever...
--the player clicks on a Sinespace UI element
thisObject = Space.Host.ExecutingObject
uiText = Space.Host.GetReference("text").UIText --Add this object with UIText component as reference in Scripting Runtime
OnUpdate = function()
if Space.Input.GetMouseDown(0) == true then
result = Space.UI.Raycast()
if result.IsValid then
uiText = result.ToString()
end
end
end
thisObject.OnUpdate(OnUpdate)Result = Distance = Space.UI.Raycast().Distance--This script will update a UIText element with the Distance of the UIRaycast whenever
--the player clicks on a Sinespace UI element
thisObject = Space.Host.ExecutingObject
uiText = Space.Host.GetReference("text").UIText --Add this object with UIText component as reference in Scripting Runtime
OnUpdate = function()
if Space.Input.GetMouseDown(0) == true then
result = Space.UI.Raycast()
if result.IsValid then
uiText = result.Distance
end
end
end
thisObject.OnUpdate(OnUpdate)Index= Space.UI.Raycast().Index--This script will update a UIText element with the Index of the UIRaycast whenever
--the player clicks on a Sinespace UI element
thisObject = Space.Host.ExecutingObject
uiText = Space.Host.GetReference("text").UIText --Add this object with UIText component as reference in Scripting Runtime
OnUpdate = function()
if Space.Input.GetMouseDown(0) == true then
result = Space.UI.Raycast()
if result.IsValid then
uiText = result.Index
end
end
end
thisObject.OnUpdate(OnUpdate)Depth= Space.UI.Raycast().Depth--This script will update a UIText element with the Depth of the UIRaycast whenever
--the player clicks on a Sinespace UI element
thisObject = Space.Host.ExecutingObject
uiText = Space.Host.GetReference("text").UIText --Add this object with UIText component as reference in Scripting Runtime
OnUpdate = function()
if Space.Input.GetMouseDown(0) == true then
result = Space.UI.Raycast()
if result.IsValid then
uiText = result.Depth
end
end
end
thisObject.OnUpdate(OnUpdate)SortingLayer= Space.UI.Raycast().SortingLayer--This script will update a UIText element with the Sorting Layer of the UIRaycast whenever
--the player clicks on a Sinespace UI element
thisObject = Space.Host.ExecutingObject
uiText = Space.Host.GetReference("text").UIText --Add this object with UIText component as reference in Scripting Runtime
OnUpdate = function()
if Space.Input.GetMouseDown(0) == true then
result = Space.UI.Raycast()
if result.IsValid then
uiText = result.SortingLayer
end
end
end
thisObject.OnUpdate(OnUpdate)SortingOrder= Space.UI.Raycast().SortingOrder--This script will update a UIText element with the Sorting Order of the UIRaycast whenever
--the player clicks on a Sinespace UI element
thisObject = Space.Host.ExecutingObject
uiText = Space.Host.GetReference("text").UIText --Add this object with UIText component as reference in Scripting Runtime
OnUpdate = function()
if Space.Input.GetMouseDown(0) == true then
result = Space.UI.Raycast()
if result.IsValid then
uiText = result.SortingOrder
end
end
end
thisObject.OnUpdate(OnUpdate)WorldPosition= Space.UI.Raycast().WorldPosition--This script will update a UIText element with the World Position of the UIRaycast whenever
--the player clicks on a Sinespace UI element
thisObject = Space.Host.ExecutingObject
uiText = Space.Host.GetReference("text").UIText --Add this object with UIText component as reference in Scripting Runtime
OnUpdate = function()
if Space.Input.GetMouseDown(0) == true then
result = Space.UI.Raycast()
if result.IsValid then
uiText = result.WorldPosition
end
end
end
thisObject.OnUpdate(OnUpdate)WorldNormal= Space.UI.Raycast().WorldNormal--This script will update a UIText element with the World Normal of the UIRaycast whenever
--the player clicks on a Sinespace UI element
thisObject = Space.Host.ExecutingObject
uiText = Space.Host.GetReference("text").UIText --Add this object with UIText component as reference in Scripting Runtime
OnUpdate = function()
if Space.Input.GetMouseDown(0) == true then
result = Space.UI.Raycast()
if result.IsValid then
uiText = result.WorldNormal
end
end
end
thisObject.OnUpdate(OnUpdate)ScreenPosition= Space.UI.Raycast().ScreenPosition--This script will update a UIText element with the Screen Position of the UIRaycast whenever
--the player clicks on a Sinespace UI element
thisObject = Space.Host.ExecutingObject
uiText = Space.Host.GetReference("text").UIText --Add this object with UIText component as reference in Scripting Runtime
OnUpdate = function()
if Space.Input.GetMouseDown(0) == true then
result = Space.UI.Raycast()
if result.IsValid then
uiText = result.ScreenPosition
end
end
end
thisObject.OnUpdate(OnUpdate)GameObject= Space.UI.Raycast().GameObject--This script will update a UIText element with the name of the UIRaycast
--by accesing it's GameObject whenever the player clicks on a Sinespace UI element
thisObject = Space.Host.ExecutingObject
uiText = Space.Host.GetReference("text").UIText --Add this object with UIText component as reference in Scripting Runtime
OnUpdate = function()
if Space.Input.GetMouseDown(0) == true then
result = Space.UI.Raycast()
if result.IsValid then
uiText = result.GameObject.Name
end
end
end
thisObject.OnUpdate(OnUpdate)IsValid= Space.UI.Raycast().IsValid--This script will check if Raycast result is valid
--and update a UIText element with the result of a UIRaycast whenever
--the player clicks on a Sinespace UI element
thisObject = Space.Host.ExecutingObject
uiText = Space.Host.GetReference("text").UIText --Add this object with UIText component as reference in Scripting Runtime
OnUpdate = function()
if Space.Input.GetMouseDown(0) == true then
result = Space.UI.Raycast()
if result.IsValid then
uiText = result.ToString()
end
end
end
thisObject.OnUpdate(OnUpdate)void SetTextureScale (string key, float x, float y)
void SetVector (string key, SVector value)
bool Contains ( point) bool Contains ( point, bool allowInverse)
Returns true if the x and y components of point is a point inside this rectangle. If allowInverse is present and true, the width and height of the Rect are allowed to take negative values (ie, the min value is greater than the max), and the test will still work.
bool Overlaps (SRect other) bool Overlaps (SRect other, bool allowInverse)
Returns true if the other rectangle overlaps this one. If allowInverse is present and true, the widths and heights of the Rects are allowed to take negative values (ie, the min value is greater than the max), and the test will still work.
bool Equals (SRect other)
Returns true if the rectangles are the same.
string ToString (string format) string ToString ()
Returns string for this Rect.
static SRect New (float x, float y, float width, float height)
Constructs a new SRect
float X get set
Property Description
float Y get set
Property Description
float Width get set
Property Description
float Height get set
Property Description
Position get
The X and Y position of the rectangle.
Center get
The position of the center of the rectangle.
Min get
The position of the minimum corner of the rectangle.
Max get
The position of the maximum corner of the rectangle.
Size get
The width and height of the rectangle.
float XMin get
The minimum X coordinate of the rectangle.
float YMin get
The minimum Y coordinate of the rectangle.
float XMax get
The maximum Y coordinate of the rectangle.
float YMax get
The maximum Y coordinate of the rectangle.
float Left get
Property Description
float Right get
Property Description
float Top get
Property Description
float Bottom get
Property Description
float get
float get
float get
float get
float get
float get
float get
bool Equals (SRect other)
Static Functions
static SRect New (float x, float y, float width, float height)
float X get set
float Y get set
float Width get set
float Height get set
SVector Position get
SVector Center get
SVector Min get
SVector Max get
SVector Size get
float get
string ()
float (SQuaternion b)
SQuaternion (SQuaternion b, float t)
SQuaternion (SQuaternion b, float t)
SQuaternion (SQuaternion b, float delta)
float (SQuaternion b)
bool (SQuaternion other)
Static Functions
static SQuaternion (float x, float y, float z, float w)
static SQuaternion (float x, float y, float z)
float get set
float get set
float get set
float get set
SVector get
SQuaternion get
Static Properties
static SQuaternion get
string ToString ()
Converts a quaternion to a human readable string
float Angle (SQuaternion b)
Returns the angle between two quaternions
SQuaternion Lerp (SQuaternion b, float t)
Linearly interpolates between this and other quaternion, by factor t and returns the result
SQuaternion Slerp (SQuaternion b, float t)
Spherically interpolates between this and other quaternion, by factor t and returns the result
SQuaternion RotateTowards (SQuaternion b, float delta)
Rotates this towards other, by no more than t degrees
float Dot (SQuaternion b)
Returns the dot product of this and another quaternion
bool Equals (SQuaternion other)
Function Description
other
SQuaternion
The other Quaternion that we are comparing with.
static SQuaternion New (float x, float y, float z, float w)
Creates a new Quaternion
static SQuaternion Euler (float x, float y, float z)
Creates a quaternion using Euler angles.
static SQuaternion AngleAxis (SVector axis, float angle)
Creates a quaternion from an Angle/Axis pair
static SQuaternion LookRotation (SVector forward) static SQuaternion LookRotation (SVector forward, SVector up)
Creates a quaternion a forward vector; presuming up is (0,1,0)
static SVector operator* (SQuaternion a, SVector b) static SQuaternion operator* (SQuaternion a, SQuaternion b)
The result of using the * operator.
static SQuaternion FromToRotation (SVector a, SVector b)
Creates a rotation which rotates from a to b.
Usually you use this to rotate a transform so that one of its axes eg. the y-axis - follows a target direction b in world space.
float X get set
X axis
float Y get set
Y axis
float Z get set
Z axis
float W get set
W axis
SVector EulerAngles get
Returns the Euler rotation for this Quaternion
SQuaternion Inverse get
Returns the inverse of this quaternion
static SQuaternion Identity get
Equivalent of new SQuaternion(0,0,0,1)
newRect=Rect.New(0,0,150,150)
otherRect = Rect.New(0,0,150,150)
isContains = newRect.Contains(otherRect)
--or
isContains = newRect.Contains(otherRect , true)newRect=Rect.New(0,0,150,150)
otherRect = Rect.New(0,0,150,150)
isOverlapping = newRect.Overlaps(otherRect)
--or
isOverlapping = newRect.Overlaps(otherRect , true)newRect=Rect.New(0,0,150,150)
otherRect = Rect.New(0,0,150,150)
AreEqual = newRect.Equals(otherRect)newRect=Rect.New(0,0,150,150)
otherRect = Rect.New(0,0,150,150)
AreEqual = newRect.Equals(otherRect)newRect=Rect.New(0,0,150,150)newRect=Rect.New(0,0,150,150)
newRect.X = 10.0newRect=Rect.New(0,0,150,150)
newRect.Y = 10.0newRect=Rect.New(0,0,150,150)
newRect.Width = 10.0newRect=Rect.New(0,0,150,150)
newRect.Height = 10.0newRect=Rect.New(50,50,150,150)
positionVector = newRect.positionnewRect = Rect.New(50,50,150,150)
VectorCenter = newRect.CenternewRect=Rect.New(0,0,150,150)
vectorMin = newRect.MinnewRect=Rect.New(0,0,150,150)
vectorMax = newRect.MaxnewRect=Rect.New(0,0,150,150)
vectorSize = newRect.SizenewRect=Rect.New(0,0,150,150)
floatXMin = newRect.XMinnewRect=Rect.New(0,0,150,150)
floatYMin = newRect.YMinnewRect=Rect.New(0,0,150,150)
floatXMax = newRect.XMaxnewRect=Rect.New(0,0,150,150)
floatYMax = newRect.YMaxnewRect=Rect.New(0,0,150,150)
floatLeft = newRect.LeftnewRect=Rect.New(0,0,150,150)
floatRight = newRect.RightnewRect=Rect.New(0,0,150,150)
floatTop = newRect.TopnewRect=Rect.New(0,0,150,150)
floatBottom = newRect.BottomaQuaternion = Quaternion.New(0.0, 1.0, 0.0, 0.0)
theString = aQuaternion.ToString()local newQuat = Quaternion.New(0.0, 0.707, 0.0, 0.707);
local otherQuat = Quaternion.New(0.0, 1.0, 0.0, 0.0);
angle = newQuat.Angle(otherQuat);
Space.Log(angle);
-- prints 90.0173034667969QuatA = Quaternion.New(0.0, 0.707, 0.0, 0.707)
QuatB = Quaternion.New(0.0, 1.0, 0.0, 0.0)
QuatLerpAB = QuatA.Lerp(QuatB, Space.Time * 0.1)local cube = Space.Host.ExecutingObject
local fromQuat = cube.LocalRotation
local toQuat = Quaternion.New(0.0, 0.707, 0.0, 0.707)
local speed = 0.1
-- The cube will rotate 90 degrees from current rotation by speed amount.
local moveCube = function()
cube.LocalRotation = fromQuat.Lerp(toQuat, Space.Time * speed);
end
cube.OnUpdate(moveCube)QuatA = Quaternion.New(0.0, 0.707, 0.0, 0.707)
QuatB = Quaternion.New(0.0, 1.0, 0.0, 0.0)
QuatLerpAB = QuatA.Slerp(QuatB, Space.Time * 0.1)local cube = Space.Host.ExecutingObject;
local fromQuat = cube.LocalRotation;
local toQuat = Quaternion.New(0.0, 1.0, 0.0, 0.0);
local speed = 0.1;
-- The cube will rotate 180 degrees from current rotation by speed amount.
local moveCube = function()
cube.LocalRotation = fromQuat.Slerp(toQuat, Space.Time * speed)
end
cube.OnUpdate(moveCube)QuatA = Quaternion.New(0.0, 0.707, 0.0, 0.707)
QuatB = Quaternion.New(0.0, 1.0, 0.0, 0.0)
ARotatedTowardB = QuatA.RotateTowards(QuatB, Space.Time * 0.1)local cube = Space.Host.ExecutingObject
local fromQuat = cube.LocalRotation
local target = Quaternion.New(0.0, 0.707, 0.0, 0.707)
local speed = 10.0
-- The cube will rotate 90 degrees from current rotation by step amount.
local moveCube = function()
local step = speed * Space.Time
cube.LocalRotation = fromQuat.RotateTowards(target, step)
end
cube.OnUpdate(moveCube)local quat = Quaternion.New(0.0, 0.707, 0.0, 0.707);
local quatOther = Quaternion.New(0.0, 0.0, 0.0, 1.0);
Space.Log(quat.Dot(quatOther));
-- prints 0.707000017166138QuatA = Quaternion.New(0.0, 0.707, 0.0, 0.707)
QuatB = Quaternion.New(0.0, 1.0, 0.0, 0.0)
isEqual = QuatA.Equals(QuatB)newQuat = Quaternion.New(0.0, 0.707, 0.0, 0.707)newQuat = Quaternion.Euler(0.0, 90.0, 0.0)newVector = Vector.New(0.0, 90.0, 0.0)
newQuat = Quaternion.AngleAxis(newVector, 90.0)local newQuat = Quaternion.LookRotation(Vector.Forward);
-- or
local newQuat = Quaternion.LookRotation(Vector.Forward, Vector.Up);newQuat = Quaternion.New(0.0, 1.0, 0.0, 0.0)
newVector = Vector.Forward
rotatedVector = newQuat * newVector
--or
newQuat = Quaternion.New(0.0, 0.707, 0.0, 0.707)
newVector = Vector.New(0.0, 0.0, 0.0)
rotatedVector = newQuat * newQuatVectorA = Vector.New(0.0,1.0,0.0)
VectorB = Vector.New(1.0,0.0,0.0)
QuaternionFromToRotation = Quaternion.FromToRotation(VectorA, VectorB)newQuat = Quaternion.New(0.0, 1.0, 0.0, 0.0)
newQuat.X = 40.0obj = Space.Host.ExecutingObject
originalRot = obj.LocalRotation
onStartMethod = function()
Space.Log(originalRot.x)
-- prints the X component of this object as a float
originalRot.x = 0.25
-- assigns 0.25 value to the X component
obj.LocalRotation = originalRot
-- sets the the new rotation
end
obj.OnStart(onStartMethod)newQuat = Quaternion.New(0.0, 1.0, 0.0, 0.0)
newQuat.Y = 40.0 obj = Space.Host.ExecutingObject
originalRot = obj.LocalRotation
onStartMethod = function()
Space.Log(originalRot.y);
-- prints the Y component of this object as a float
originalRot.y = 0.25;
-- assigns 0.25 value to the Y component
obj.LocalRotation = originalRot;
-- sets the the new rotation
end
obj.OnStart(onStartMethod);newQuat = Quaternion.New(0.0, 1.0, 0.0, 0.0)
newQuat.Z = 40.0local obj = Space.Host.ExecutingObject;
local originalRot = obj.LocalRotation;
obj.SubscribeToEvents();
local onStartMethod = function()
Space.Log(originalRot.z);
-- prints the Z component of this object as a float
originalRot.z = 0.25;
-- assigns 0.25 value to the Z component
obj.LocalRotation = originalRot;
-- sets the the new rotation
end
obj.OnStart(onStartMethod);newQuat = Quaternion.New(0.0, 1.0, 0.0, 0.0)
newQuat.W = 40.0local obj = Space.Host.ExecutingObject;
local originalRot = obj.LocalRotation;
obj.SubscribeToEvents();
local onStartMethod = function()
Space.Log(originalRot.w);
-- prints the W component of this object as a float
originalRot.w = 0.25;
-- assigns 0.25 value to the W component
obj.LocalRotation = originalRot;
-- sets the the new rotation
end
obj.OnStart(onStartMethod);newQuat = Quaternion.New(0.0, 0.707, 0.0, 0.707)
euler = newQuat.EulerAnglesquat = Quaternion.New(0.0, 0.707, 0.0, 0.707)
inverseQuat = quat.Inverseidentity = Quaternion.Identitystatic SQuaternion AngleAxis (SVector axis, float angle)
static SQuaternion LookRotation (SVector forward) static SQuaternion LookRotation (SVector forward, SVector up)
static SQuaternion FromToRotation (SVector a, SVector b)
bool Equals (SDateTime other)
Returns true if the datetimes are same.
int ComparesTo (SDateTime other)
Compares two datetimes and returns an integer. 0 == identical. greater than 0 == This datetime is greater than other. less than 0 == This datetime is less than other.
string FormatLocal (string format)
Outputs a custom formatted string with the date and time according to local language rules.
string FormatGlobal (string format)
Outputs a custom formatted string with the date and time according to global rules (culture invariant).
string Regional (string region)
Outputs a string with the date and time formatted according to specific regional rules.
string FormatRegional (string region, string format)
Outputs a custom formatted string with the date and time according to specific regional rules.
SDateTime AddYears (int amount)
Return a new SDateTime that is the current date time + amount years.
SDateTime AddMonths (int amount)
Return a new SDateTime that is the current date time + amount months.
SDateTime AddDays (double amount)
Return a new SDateTime that is the current date time + amount days.
SDateTime AddHours (double amount)
Return a new SDateTime that is the current date time + amount hours.
SDateTime AddMinutes (double amount)
Return a new SDateTime that is the current date time + amount minutes.
SDateTime AddSeconds (double amount)
Return a new SDateTime that is the current date time + amount seconds.
SDateTime AddMilliseconds (double amount)
Return a new SDateTime that is the current date time + amount milliseconds.
static SDateTime Now()
Creates a new SDateTime object equal to the current local time.
static SDateTime Server ()
Creates a new SDateTime object equal to the current server time.
static SDateTime Parse (string input)
Creates a new SDateTime object by attempting to parse a string input. Returns null/nil if the string cannot be parsed.
static bool IsLeapYear (int year)
Return true if the specified year is a leap year.
static int DaysInMonth (int year, int month)
Return the number of days in the given month for the given year.
int Year get
Get the independent time unit property of the SDateTime object.
int Month get
Property Description
int Day get
Property Description
int Hour get
Property Description
int Minute get
Property Description
int Second get
Property Description
int Millisecond get
Property Description
string Local get
Outputs a string with the date and time formatted according to local language rules.
string Global get
Outputs a string with the date and time formatted according to global rules (culture invariant).
int UnixTime get
Return this time in Unix time, the number of seconds since Jan 1st, 1970.
bool IsDaylightSavingTime get
Indicates whether this instance of DateTime is within the daylight saving time range for the current time zone.
SDateTime (double amount)
Static Functions
static SDateTime ()
static SDateTime ()
static SDateTime (string input)
static bool (int year)
static int (int year, int month)
bool get
bool Equals (SDateTime other)
int ComparesTo (SDateTime other)
string FormatLocal (string format)
string FormatGlobal (string format)
string Regional (string region)
string FormatRegional (string region, string format)
SDateTime AddYears (int amount)
SDateTime AddMonths (int amount)
SDateTime AddDays (double amount)
SDateTime AddHours (double amount)
SDateTime AddMinutes (double amount)
int Year get
int Month get
int Day get
int Hour get
int Minute get
int Second get
int Millisecond get
string Local get
string Global get
format
string
See below for examples
region
string
region
string
format
string
See below
SDateTime (double amount)
int get
ATargetDateTime = DateTime.Now().AddMinutes(5)
AreEqual = ATargetDateTime.Equals(DateTime.Now())ATargetDateTime = DateTime.Now().AddMinutes(5)
AreEqual = ATargetDateTime.ComparesTo(DateTime.Now())localTimeCustomFormat = DateTime.Now().FormatLocal("dddd, MMMM dd, yyyy h:mm:ss tt")--Example format strings
--[[
format = "dddd, MMMM dd, yyyy h:mm:ss tt"
Result: Monday, May 28, 2012 11:35:00 AM
format = "Ldddd, MMMM dd, yyyy"
Result: Monday, May 28, 2012
format = "h:mm:ss tt"
Result: 11:35:00 AM
format = "MMMM dd"
Result: May 28
format = "ddd, dd MMM yyyy HH':'mm':'ss 'GMT"
Result: Mon, 28 May 2012 11:35:00 GMT
format = "M/d/yyyy"
Result: 5/28/2012
format = "h:mm tt"
Result: 11:35 AM
format = "yyyy'-'MM'-'dd'T'HH':'mm':'ss"
Result: 2012-05-28T11:35:00
format = "yyyy'-'MM'-'dd HH':'mm':'ss'Z'"
Result: 2012-05-28 11:35:00Z
format = "MMMM, yyyy"
Result: May, 2012
--]]GlobalTimeCustomFormat = DateTime.Now().FormatLocal("dddd, MMMM dd, yyyy h:mm:ss tt")--Example format strings
--[[
format = "dddd, MMMM dd, yyyy h:mm:ss tt"
Result: Monday, May 28, 2012 11:35:00 AM
format = "Ldddd, MMMM dd, yyyy"
Result: Monday, May 28, 2012
format = "h:mm:ss tt"
Result: 11:35:00 AM
format = "MMMM dd"
Result: May 28
format = "ddd, dd MMM yyyy HH':'mm':'ss 'GMT"
Result: Mon, 28 May 2012 11:35:00 GMT
format = "M/d/yyyy"
Result: 5/28/2012
format = "h:mm tt"
Result: 11:35 AM
format = "yyyy'-'MM'-'dd'T'HH':'mm':'ss"
Result: 2012-05-28T11:35:00
format = "yyyy'-'MM'-'dd HH':'mm':'ss'Z'"
Result: 2012-05-28 11:35:00Z
format = "MMMM, yyyy"
Result: May, 2012
--]]stringTimeRegional = DateTime.Now().Regional('en-us')stringTimeFormatRegional = DateTime.Now().FormatRegional('en-us','dddd, MMMM dd, yyyy h:mm:ss tt')--Example format strings
--[[
format = "dddd, MMMM dd, yyyy h:mm:ss tt"
Result: Monday, May 28, 2012 11:35:00 AM
format = "Ldddd, MMMM dd, yyyy"
Result: Monday, May 28, 2012
format = "h:mm:ss tt"
Result: 11:35:00 AM
format = "MMMM dd"
Result: May 28
format = "ddd, dd MMM yyyy HH':'mm':'ss 'GMT"
Result: Mon, 28 May 2012 11:35:00 GMT
format = "M/d/yyyy"
Result: 5/28/2012
format = "h:mm tt"
Result: 11:35 AM
format = "yyyy'-'MM'-'dd'T'HH':'mm':'ss"
Result: 2012-05-28T11:35:00
format = "yyyy'-'MM'-'dd HH':'mm':'ss'Z'"
Result: 2012-05-28 11:35:00Z
format = "MMMM, yyyy"
Result: May, 2012
--]]date5YearsLater = DateTime.Now().AddYears(5)date5MonthsLater = DateTime.Now().AddMonths(5)date5DaysLater = DateTime.Now().AddDays(5)date5HoursLater = DateTime.Now().AddHours(5)date5MinutesLater = DateTime.Now().AddMinutes(5)date5SecondsLater = DateTime.Now().AddSeconds(5)date5MillisecondsLater = DateTime.Now().AddMilliseconds(5)localDateTime = DateTime.Now()serverDateTime = DateTime.Server()parseDateTime = DateTime.Parse('10/3/2022 1:26:02 PM')isLeapYear = DateTime.IsLeapYear(2024)isLeapYear = DateTime.DaysInMonth(2022, 8)currentYear = DateTime.Now().YearcurrentMonth = DateTime.Now().MonthcurrentDay = DateTime.Now().DaycurrentHour = DateTime.Now().HourcurrentMinute = DateTime.Now().MinutecurrentSecond = DateTime.Now().SecondcurrentMillisecond = DateTime.Now().MillisecondcurrentTimeStringLocal = DateTime.Now().LocalcurrentTimeStringGlobal = DateTime.Now().GlobalcurrentUnixTime = DateTime.Now().UnixTimeisCurrentTimeDaylightSaving = DateTime.Now().IsDaylightSavingTimeSVector Add (SVector other) SVector Add (float other)
Adds this Vector
SVector Scale (SVector other) SVector Scale (float other)
Multiplies this Vector
SVector Divide (SVector other) SVector Divide (float other)
Divides this Vector
float Distance (SVector other)
Returns the distance between this vector and other in meters
float SquareDistance (SVector other)
Returns the square of the distance between this vector and other in meters, considerably faster than distance()
bool InRange (SVector other, float range)
Returns if other is within range meters of this vector, inclusive
SVector Cross (SVector other)
Returns the cross product of this vector and other
SVector Lerp (SVector other, float t)
Linear interpolates between this and other based on factor t (0-1)
SVector Slerp (SVector other, float t)
Spherically linear interpolates between this and other based on factor t (0-1)
SVector MoveTowards (SVector other, float maxDistance)
Moves this vector closer to other by a maximum of maxDistance units
float Dot (SVector other)
Returns the dot product between this and other (note - normalise your vectors first!
bool Equals (SVector other)
Function Description
string ToString ()
Function Description
static SVector New (float x, float y, float z)
Initialises vector from three floats
static SVector operator+ (SVector a, SVector b) static SVector operator+ (SVector a, float b)
Function Description
static SVector operator- (SVector a, SVector b) static SVector operator- (SVector a, float b)
Function Description
static SVector operator* (SVector a, SVector b) static SVector operator* (SVector a, float b)
Function Description
static SVector operator/ (SVector a, SVector b) static SVector operator/ (SVector a, float b)
Function Description
float X get set
X axis (red axis)
float Y get set
Y axis (green axis)
float Z get set
Z axis (blue axis)
float Magnitude get
Returns the magnitude of this vector
SVector Normalised get
Returns the normalised version of this vector
static SVector Up get
Equivalent of new SVector(0,1,0)
static SVector Down get
Equivalent of new SVector(0,-1,0)
static SVector Left get
Equivalent of new SVector(-1,0,0)
static SVector Right get
Equivalent of new SVector(1,0,0)
static SVector Forward get
Equivalent of new SVector(0,0,1)
static SVector Back get
Equivalent of new SVector(0,0,-1)
static SVector Zero get
Equivalent of new SVector(0,0,0)
static SVector One get
Equivalent of new SVector(1,1,1)
static SVector MaxValue get
Contains the largest possible vector [3.402823E+38, 3.402823E+38, 3.402823E+38]
static SVector MinValue get
Contains the largest possible negative vector
string ()
Static Functions
static SVector (float x, float y, float z)
static SVector + (SVector a, SVector b) static SVector + (SVector a, float b)
static SVector - (SVector a, SVector b) static SVector - (SVector a, float b)
static SVector * (SVector a, SVector b) static SVector * (SVector a, float b)
static SVector / (SVector a, SVector b) static SVector / (SVector a, float b)
static SVector get
static SVector get
static SVector get
static SVector get
static SVector get
static SVector get
static SVector get
float Distance (SVector other)
float SquareDistance (SVector other)
bool InRange (SVector other, float range)
SVector Cross (SVector other)
SVector Lerp (SVector other, float t)
SVector Slerp (SVector other, float t)
SVector MoveTowards (SVector other, float maxDistance)
float Dot (SVector other)
float X get set
float Y get set
float Z get set
float Magnitude get
SVector Normalised get
Static Properties
static SVector Up get
static SVector Down get
bool (SVector other)
static SVector get
local vector = Vector.New(0, 10, 0);
local vectorOther = Vector.New(40, 50, 6);
Space.Log(vector.Add(vectorOther));
-- prints [40, 60, 6]
Space.Log(vector + vectorOther);
-- prints [40, 60, 6]local vectorB = Vector.New(0, 10, 0);
Space.Log(vectorB.Add(5));
-- prints [5, 15, 5]local vector = Vector.New(0, 10, 0);
local vectorOther = Vector.New(2, 5, 4);
Space.Log(vector.Scale(vectorOther));
-- prints [0, 50, 0]
Space.Log(vector * vectorOther);
-- prints [0, 50, 0]local vector = Vector.New(0, 10, 0);
Space.Log(vector.Scale(5));
-- prints [0, 50, 0]
Space.Log(vector * 5);
-- prints [0, 50, 0]local vector = Vector.New(10, 10, 10);
local vectorOther = Vector.New(2, 2, 2);
Space.Log(vector.Divide(vectorOther));
-- prints [5, 5, 5]
Space.Log(vector / vectorOther);
-- prints [5, 5, 5]local vector = Vector.New(10, 10, 10);
Space.Log(vector.Divide(2));
-- prints [5, 5, 5]
Space.Log(vector / 2);
-- prints [5, 5, 5]local vector = Vector.New(3, 3, 3.5);
local vectorOther = Vector.New(2, 2, 2);
Space.Log(vector.Distance(vectorOther));
-- prints 2.06155276298523--the below script will change the objects color to green if you are near the object
--and change color to red if you are far from the object
thisGameObject = Space.Host.ExecutingObject
function OnUpdate()
positionAvatar = Space.Scene.PlayerAvatar.GameObject.WorldPosition
positionObject = thisGameObject.WorldPosition
if positionAvatar.Distance(positionObject) < 5 then
thisGameObject.Renderer.Material.SetColor("_Color",0,1,0,1)
else
thisGameObject.Renderer.Material.SetColor("_Color",1,0,0,1)
end
end
thisGameObject.OnUpdate(OnUpdate)local vector = Vector.New(3, 3, 3.5);
local vectorOther = Vector.New(2, 2, 2);
Space.Log(vector.SquareDistance(vectorOther));
-- prints 4.25--the below script will change the objects color to green if you are near the object
--and change color to red if you are far from the object
thisGameObject = Space.Host.ExecutingObject
function OnUpdate()
positionAvatar = Space.Scene.PlayerAvatar.GameObject.WorldPosition
positionObject = thisGameObject.WorldPosition
if positionAvatar.SquareDistance(positionObject) < 25 then
thisGameObject.Renderer.Material.SetColor("_Color",0,1,0,1)
else
thisGameObject.Renderer.Material.SetColor("_Color",1,0,0,1)
end
end
thisGameObject.OnUpdate(OnUpdate)local vector = Vector.New(370, 30, 0);
local vectorOther = Vector.New(372, 30, 0);
Space.Log(vector.InRange(vectorOther, 2.0));
-- prints True
local vector2 = Vector.New(80, 30, 20);
local vectorOther2 = Vector.New(1, 15, 25);
Space.Log(vector2.InRange(vectorOther2, 1.0));
-- prints False--the below script will change the objects color to green if you are near the object
--and change color to red if you are far from the object
--(example: motion sensor lights)
thisGameObject = Space.Host.ExecutingObject
function OnUpdate()
positionAvatar = Space.Scene.PlayerAvatar.GameObject.WorldPosition
positionObject = thisGameObject.WorldPosition
if positionAvatar.InRange(positionObject, 5.0) then
thisGameObject.Renderer.Material.SetColor("_Color",0,1,0,1)
else
thisGameObject.Renderer.Material.SetColor("_Color",1,0,0,1)
end
end
thisGameObject.SubscribeToEvents()
thisGameObject.OnUpdate(OnUpdate)local vector = Vector.New(0, 1, 0);
local vectorOther = Vector.New(1, 0, 0);
Space.Log(vector.Cross(vectorOther));
-- prints [0, 0, -1]lerpVector = currentVector.Lerp(targetVector, 0.5)-- Lua Translation of Unity C# Documentation
--[["StartMarker" and "EndMaker" are game objects set up as endpoints.
These objects are attached to the script in the Object Reference section.
The name fields in that section should match these names for the example. --]]
local startMarker = Space.Host.GetReference("StartMarker");
local endMarker = Space.Host.GetReference("EndMarker");
local ball = Space.Host.ExecutingObject;
local speed = 1.0;
local startTime;
local journeyLength;
ball.SubscribeToEvents();
local onStartMethod = function()
startTime = Space.Time;
journeyLength = startMarker.LocalPosition.Distance(endMarker.LocalPosition);
end
-- This ball object will move from the start endpoint object to the end endpoint.
local moveBall = function()
local distCovered = (Space.Time - startTime) * speed;
local fracJourney = distCovered / journeyLength;
ball.LocalPosition = startMarker.LocalPosition.Lerp(endMarker.LocalPosition, fracJourney);
end
ball.OnStart(onStartMethod);
ball.OnUpdate(moveBall);slerpVector = currentVector.Slerp(targetVector, 0.5)-- Lua Translation of Unity C# Documentation
--[["Sunrise" and "Sunset" are game objects set up as endpoints.
These objects are attached to the script in the Object Reference section.
The name fields in that section should match these names for the example. --]]
local sunrise = Space.Host.GetReference("Sunrise");
local sunset = Space.Host.GetReference("Sunset");
local ball = Space.Host.ExecutingObject;
local startTime;
local journeyTime = 1.0;
ball.SubscribeToEvents();
local onStartMethod = function()
startTime = Space.Time;
end
-- This ball object will move from the start endpoint object to the end endpoint.
local moveBall = function()
local center = (sunrise.LocalPosition + sunset.LocalPosition) * 0.5;
center = center - Vector.Up;
local riseRelCenter = sunrise.LocalPosition - center;
local setRelCenter = sunset.LocalPosition - center;
local fracComplete = (Space.Time - startTime) / journeyTime;
ball.LocalPosition = riseRelCenter.Slerp(setRelCenter, fracComplete);
ball.LocalPosition = ball.LocalPosition + center;
end
ball.OnStart(onStartMethod);
ball.OnUpdate(moveBall);newVector = currentVector.MoveTowards(targetVector)-- Lua Translation of Unity C# Documentation
--[["Target" is a game object set up as a target position.
This object is attached to the script in the Object Reference section.
The name field in that section should match this name for the example. --]]
local target = Space.Host.GetReference("Target");
local ball = Space.Host.ExecutingObject;
local speed = 1.0;Vecto
local onStartMethod = function()
startTime = Space.Time;
end
-- This ball object will move towards the target. Negative values for
-- the maxDistance parameter will push the ball away from the target.
local moveBall = function()
local step = speed * Space.DeltaTime;
ball.LocalPosition = ball.LocalPosition.MoveTowards(target.LocalPosition, step);
end
ball.OnStart(onStartMethod);
ball.OnUpdate(moveBall);
-- NOTE: If you use MoveTowards, the movement will not overshoot the target.local vectorA = Vector.New(0, 1, 0);
local vectorOtherA = Vector.New(1, 0, 0);
Space.Log(vectorA.Dot(vectorOtherA));
-- prints 0
local vectorB = Vector.New(0, 1, 0);
local vectorOtherB = Vector.New(0, 1, 0);
Space.Log(vectorB.Dot(vectorOtherB));
-- prints 1
local vectorC = Vector.New(0, 1, 0);
local vectorOtherC = Vector.New(0, -1, 0);
Space.Log(vectorC.Dot(vectorOtherC));
-- prints -1isEqual = Vector.Up.Equals( Vector.New(0,1,0) )stringVector = Vector.New(0,0,0).ToString()newVector = Vector.New(0, 1, 0)example 1example 1example 1example 1newVect = Vector.New(0,0,0)
newVect.X = 5.0local obj = Space.Host.ExecutingObject;
local originalPos = obj.LocalPosition;
obj.SubscribeToEvents();
local onStartMethod = function()
Space.Log(originalPos.x);
-- prints the X axis position of this object as a float
originalPos.x = 100.0;
-- assigns 100.0 value to the X axis position of this object
obj.LocalPosition = originalPos;
-- sets the the new position
end
obj.OnStart(onStartMethod);newVect = Vector.New(0,0,0)
newVect.Y = 5.0local obj = Space.Host.ExecutingObject;
local originalPos = obj.LocalPosition;
obj.SubscribeToEvents();
local onStartMethod = function()
Space.Log(originalPos.y);
-- prints the Y axis position of this object as a float
originalPos.y = 100.0;
-- assigns 100.0 value to the Y axis position of this object
obj.LocalPosition = originalPos;
-- sets the the new position
end
obj.OnStart(onStartMethod);newVect = Vector.New(0,0,0)
newVect.Z = 5.0local obj = Space.Host.ExecutingObject
local originalPos = obj.LocalPosition
local onStartMethod = function()
Space.Log(originalPos.z)
-- prints the Z axis position of this object as a float
originalPos.z = 100.0
-- assigns 100.0 value to the Z axis position of this object
obj.LocalPosition = originalPos
-- sets the the new position
end
obj.OnStart(onStartMethod)vector = Vector.New(1.0, 5.0, 0.0)
vectorMagnitude = vector.Magnitudevector = Vector.New(0.0, 10.0, 0.0)
vectorNormalised = vector.Normalisedup = Vector.Up--this script will make clicking this object move 2 units up on the world Y axis
thisObject = Space.Host.ExecutingObject
OnClick = function()
thisObject.WorldPosition = thisObject.WorldPosition + (Vector.Up * 2)
end
thisObject.AddClickable()
thisObject.Clickable.OnClick(OnClick)down = Vector.Down--this script will make clicking this object move 2 units down on the world Y axis
thisObject = Space.Host.ExecutingObject
OnClick = function()
thisObject.WorldPosition = thisObject.WorldPosition + (Vector.Down * 2)
end
thisObject.AddClickable()
thisObject.Clickable.OnClick(OnClick)left = Vector.Left--this script will make clicking this object move 2 units left on the world X axis
thisObject = Space.Host.ExecutingObject
OnClick = function()
thisObject.WorldPosition = thisObject.WorldPosition + (Vector.Left * 2)
end
thisObject.AddClickable()
thisObject.Clickable.OnClick(OnClick)right = Vector.Right--this script will make clicking this object move 2 units right on the world X axis
thisObject = Space.Host.ExecutingObject
OnClick = function()
thisObject.WorldPosition = thisObject.WorldPosition + (Vector.Right * 2)
end
thisObject.AddClickable()
thisObject.Clickable.OnClick(OnClick)forward = Vector.Forward--this script will make clicking this object move 2 units Forward on the world Z axis
thisObject = Space.Host.ExecutingObject
OnClick = function()
thisObject.WorldPosition = thisObject.WorldPosition + (Vector.Forward * 2)
end
thisObject.AddClickable()
thisObject.Clickable.OnClick(OnClick)back = Vector.Back--this script will make clicking this object move 2 units Back on the world Z axis
thisObject = Space.Host.ExecutingObject
OnClick = function()
thisObject.WorldPosition = thisObject.WorldPosition + (Vector.Back * 2)
end
thisObject.AddClickable()
thisObject.Clickable.OnClick(OnClick)vectorZero = Vector.Zero--clicking this object move it to the center of the region <0,0,0>
thisObject = Space.Host.ExecutingObject
OnClick = function()
thisObject.WorldPosition = Vector.Zero
end
thisObject.AddClickable()
thisObject.Clickable.OnClick(OnClick)vectorOne = Vector.One--clicking this object move it to the <1,1,1> coordinates of the region.
thisObject = Space.Host.ExecutingObject
OnClick = function()
thisObject.WorldPosition = Vector.One
end
thisObject.AddClickable()
thisObject.Clickable.OnClick(OnClick)vectorMaxValue = Vector.MaxValuevectorMinValue = Vector.MinValuevoid AttachTo (SGameObject target)
Attaches the player to the target game object, keeping the avatar fixed in its current position/rotation relative to the target object (e.g. for use in Vehicles)
void Detach ()
Detaches the avatar from whatever it may be attached to (only works for the player avatar), including chairs, vehicles and so forth.
void OnAvatarAttached ()
An event which fires whenever this avatar is attached to a game object in the current scene.
void OnAvatarDetached ()
An event which fires whenever this avatar is detached from a game object in the current scene.
void LoadOutfit (int outfitID)
Only works on a white-label deployment due to abuse concerns. Restrictions: The outfit ID needs to be one of the grid template outfits, with all the restrictions that apply to those (i.e. must use either SW content, or content uploaded by a grid admin account).
void ResetOutfit ()
Reset current outfit. (white-label only)
void Register (string username, string password, string email, bool subscribeToSinespaceNewsletter=false, Closure onSuccess=null, Closure onError=null)
Allow a guest to register. (white-label only)
void ResetOutfitToTemplate (int outfitID)
Reset current outfit to a specific template. (white-label only)
FindBone (string bone)
Retrieves the specified humanoid bone as an SGameObject. Requires a Humanoid rig; returns nil if the bone is missing or the avatar is non‑humanoid. The name is matched case‑insensitively against UnityEngine.HumanBodyBones.
void Teleport (string landmarkName) void Teleport ( position) void Teleport ( position, rotation) void Teleport (int region) void Teleport (int region, position, rotation)
Teleport the avatar.
void SetIKGoal (string goal, bool positionGoal, float positionStrength, positionTarget, bool rotationGoal, float rotationStrength, rotationTarget)
Set the IK goal to avatar.
void ClearIKGoal (string goal)
Clear the IK Goal.
void PlayCustomAnimation ( animationClip)
Play a custom animation on the avatar.
void StopCustomAnimation ()
Make the avatar stops playing custom animation.
void OnAvatarReload (Closure o)
This event will be called when the avatar gets loaded.
void SynchroniseState ()
Synchronise avatar's state to network.
void StartFly ()
Puts the avatar into Fly Mode.
void EndFly ()
Exits Avatar out of Fly Mode
void OnAvatarSkeletonReload (Closure o)
This event will be called when the avatar skeleton gets loaded.
double TeleportToNextEvent (long withinSeconds=600)
Teleports to the region of the next scheduled event if it starts within the given time window. Returns 0 if a teleport occurs; returns the number of seconds until the next event if it is outside the cutoff; returns -1 if there are no upcoming events.
string Username get
Returns the avatar's current username (note: this can be changed by players for a small fee)
string DisplayName get
Returns the avatar's display name (falls back to Username if unset).
string Title get
Returns the avatar's current title
string OrgTitle get
Returns the user's organizational job title (JobTitle).
string OrgName get
Returns the user's organization/company name (Company).
long ID get
Returns the avatar's user ID, please note if you store these, this is a 'long' value not a 'int'.
bool IsAttached get
Returns True if avatar is Attached
float MovementSpeed get set
How fast the avatar's movement is
float JumpHeight get set
How high the avatar's jump is
bool Guest get
Is this Avatar a Guest?
long OutfitID get
Returns the current outfit ID of the avatar
bool Loaded get
Returns true if avatar is Loaded
string Gender get
Returns the avatar's gender as a string (e.g., "Male", "Female").
LockObject get
The object the Avatar is to. Returns Null if Avatar is not attached.
Skeleton get
Returns a reference to avatar's skeleton GameObject
bool BlockMovement get set
If set to True, avatar's movement will be blocked
bool BlockRun get set
Is the Avatar blocked from running?
bool BlockFly get set
Is the Avatar blocked from flying?
bool BlockCrouch get set
Is the Avatar blocked from crouching?
bool BlockJump get set
Is the Avatar blocked from jumping?
bool IsGrounded get
Returns True if avatar is Grounded
GameObject get
The reference to the Avatar's GameObject
bone
string
Name of a UnityEngine.HumanBodyBones value (case‑insensitive), e.g., "LeftShoulder", "Head".
o
Closure (callback)
A function that will be called once the OnAvatarReload event is triggered.
o
Closure (callback)
A function that will be called once the OnAvatarSkeletonReload event is triggered.
withinSeconds
long
Maximum seconds ahead to consider for auto-teleport. Defaults to 600.
Space.Scene.PlayerAvatar.AttachTo(targetObject)--the below script makes the player Attach/Detach to/from this object by clicking it
--(Example: Seat/Vehicle/Experience etc.. )
thisGameObject = Space.Host.ExecutingObject
isAttached = 0
OnClick = function()
if isAttached == 0 then
Space.Scene.PlayerAvatar.AttachTo(thisGameObject)
isAttached = 1
elseif isAttached == 1 then
Space.Scene.PlayerAvatar.Detach()
isAttached = 0
end
end
thisGameObject.AddClickable()
thisGameObject.Clickable.Tooltip = "Click to Attach/Detach yourself to/from me"
thisGameObject.Clickable.OnClick(OnClick) Space.Scene.PlayerAvatar.Detach() --the below script makes the player Attach/Detach to/from this object by clicking it
--(Example: Seat/Vehicle/Experience etc.. )
thisGameObject = Space.Host.ExecutingObject
isAttached = 0
OnClick = function()
if isAttached == 0 then
Space.Scene.PlayerAvatar.AttachTo(thisGameObject)
isAttached = 1
elseif isAttached == 1 then
Space.Scene.PlayerAvatar.Detach()
isAttached = 0
end
end
thisGameObject.AddClickable()
thisGameObject.Clickable.Tooltip = "Click to Attach/Detach yourself to/from me"
thisGameObject.Clickable.OnClick(OnClick) function OAA()
--
end
Space.Scene.PlayerAvatar.OnAvatarAttached(OAA)function OAD()
--
end
Space.Scene.PlayerAvatar.OnAvatarDetached(OAD)local avatar=Space.Scene.PlayerAvatar
avatar.LoadOutfit(10001) --the below script changes the player's outfit into
--a pre-defined outfit if they click the object containing the script
--(Example: Player clicks on a wardrobe and their outfit changes)
--[Only works on white-label deployment]
thisGameObject = Space.Host.ExecutingObject
OnClick = function()
Space.Scene.PlayerAvatar.LoadOutfit(2662469)
end
thisGameObject.AddClickable()
thisGameObject.Clickable.Tooltip = "Put on your favourite suit"
thisGameObject.Clickable.OnClick(OnClick)Space.Scene.PlayerAvatar.ResetOutfit()--Clicking this object will reset player avatar's outfit
thisObject = Space.Host.ExecutingObject
thisPlayer = Space.Scene.PlayerAvatar
OnClick = function()
thisPlayer.ResetOutfit()
end
thisObject.AddClickable()
thisObject.Clickable.OnClick(OnClick)local avatar=Space.Scene.PlayerAvatar
avatar.Register("MyName","MyPassword","MyEmail",false,function ()
Space.Log("Success!")
end,function ()
Space.Log("OnError!!")
end)local avatar=Space.Scene.PlayerAvatar
avatar.ResetOutfitToTemplate(10001)--Clicking this object will reset player avatar's outfit to a specific template.
thisObject = Space.Host.ExecutingObject
thisPlayer = Space.Scene.PlayerAvatar
OnClick = function()
thisPlayer.ResetOutfitToTemplate(10001)
end
thisObject.AddClickable()
thisObject.Clickable.OnClick(OnClick)-- Humanoid models only. Pass a UnityEngine.HumanBodyBones name.
local bone = Space.Scene.PlayerAvatar.FindBone("LeftShoulder")
Space.Log(bone.Name) -- Prints the bone name of the corresponding search parameter; on default avatars, prints "LeftShoulder"
--[[
UnityEngine.HumanBodyBones values
Body: Hips, Spine, Chest, UpperChest
Head: Neck, Jaw, Head, LeftEye, RightEye
Left Arm: LeftShoulder, LeftUpperArm, LeftLowerArm, LeftHand
Left Leg: LeftUpperLeg, LeftLowerLeg, LeftFoot, LeftToes
Right Arm: RightShoulder, RightUpperArm, RightLowerArm, RightHand
Right Leg: RightUpperLeg, RightLowerLeg, RightFoot, RightToes
Left Hand (Thumb): LeftThumbProximal, LeftThumbIntermediate, LeftThumbDistal
Left Hand (Index): LeftIndexProximal, LeftIndexIntermediate, LeftIndexDistal
Left Hand (Middle): LeftMiddleProximal, LeftMiddleIntermediate, LeftMiddleDistal
Left Hand (Ring): LeftRingProximal, LeftRingIntermediate, LeftRingDistal
Left Hand (Little): LeftLittleProximal, LeftLittleIntermediate, LeftLittleDistal
Right Hand (Thumb): RightThumbProximal, RightThumbIntermediate, RightThumbDistal
Right Hand (Index): RightIndexProximal, RightIndexIntermediate, RightIndexDistal
Right Hand (Middle): RightMiddleProximal, RightMiddleIntermediate, RightMiddleDistal
Right Hand (Ring): RightRingProximal, RightRingIntermediate, RightRingDistal
Right Hand (Little): RightLittleProximal, RightLittleIntermediate, RightLittleDistal
]] --this script will set your avatar's "right hand" as parent of this object
--this way this object will be a child of your right hand and therefore move with it
--(Example: clicking on a gun to equip it)
thisGameObject = Space.Host.ExecutingObject
OnClick = function()
RightHand = Space.Scene.PlayerAvatar.FindBone("RightHand")
thisGameObject.SetParent(RightHand)
thisGameObject.LocalPosition = Vector.New(0,0,0) -- resetting position to match hand
end
thisGameObject.AddClickable()
thisGameObject.Clickable.Tooltip="Click to Equip "
thisGameObject.Clickable.OnClick(OnClick) Space.Scene.PlayerAvatar.Teleport("MyLandMark")
--or
Space.Scene.PlayerAvatar.Teleport( Vector.New(0,0,0) )
--or
Space.Scene.PlayerAvatar.Teleport( Vector.New(0,0,0), Quaternion.New(0,0,0) )
--or
Space.Scene.PlayerAvatar.Teleport( 5432342)
--or
Space.Scene.PlayerAvatar.Teleport( 5432342, Vector.New(0,0,0), Quaternion.New(0,0,0) )--the below script teleports player to a specific landmark
--if they click the object containing it
--(Example: A region promotional/advertisement sign)
--[You need a landmark in the scene with name "Fashion Section Landmark"
thisGameObject = Space.Host.ExecutingObject
OnClick = function()
Space.Scene.PlayerAvatar.Teleport("Fashion Section Landmark")
end
thisGameObject.AddClickable()
thisGameObject.Clickable.Tooltip = "Click me to go to the fashion section!"
thisGameObject.Clickable.OnClick(OnClick)avatar=Space.Scene.PlayerAvatar
pos=avatar.FindBone("Chest").WorldPosition
avatar.SetIKGoal("Chest",false,0,pos,true,20,Quaternion.Euler(0,60,0))avatar=Space.Scene.PlayerAvatar
pos=avatar.FindBone("Chest").WorldPosition
avatar.SetIKGoal("Chest",false,0,pos,true,20,Quaternion.Euler(0,60,0))
Space.Host.InvokeDelayed(function ()
avatar.ClearIKGoal("Chest")
end,5)
-- will clear after 5 seconds.Space.Scene.PlayerAvatar.PlayCustomAnimation(Space.Resources[1]) --the below script makes the player Play/Stop a custom animation when clicking this object
--(Example: Dance Machine )
--[Required: Place an animation in the first "Resource" in the scripting runtime]
thisGameObject = Space.Host.ExecutingObject
isDancing = 0
OnClick = function()
if isDancing == 0 then
Space.Scene.PlayerAvatar.PlayCustomAnimation(Space.Resources[1])
isDancing = 1
elseif isDancing == 1 then
Space.Scene.PlayerAvatar.StopCustomAnimation()
isDancing = 0
end
end
thisGameObject.AddClickable()
thisGameObject.Clickable.Tooltip = "Click to Start/Stop dancing"
thisGameObject.Clickable.OnClick(OnClick) avatar=Space.Scene.PlayerAvatar
avatar.PlayCustomAnimation(Space.Resources[1])
avatar.StopCustomAnimation() --the below script makes the player Play/Stop a custom animation when clicking this object
--(Example: Dance Machine )
--[Required: Place an animation in the first "Resource" in the scripting runtime]
thisGameObject = Space.Host.ExecutingObject
isDancing = 0
OnClick = function()
if isDancing == 0 then
Space.Scene.PlayerAvatar.PlayCustomAnimation(Space.Resources[1])
isDancing = 1
elseif isDancing == 1 then
Space.Scene.PlayerAvatar.StopCustomAnimation()
isDancing = 0
end
end
thisGameObject.AddClickable()
thisGameObject.Clickable.Tooltip = "Click to Start/Stop dancing"
thisGameObject.Clickable.OnClick(OnClick) local avatar=Space.Scene.PlayerAvatar
avatar.OnAvatarReload(function ()
Space.Log(avatar.OutfitID)
end)--this script ensures the avatar is still animating after their avatar gets reloaded
thisPlayer = Space.Scene.PlayerAvatar
theAnimation = Space.GetResource("The Animation") --add animation to resources in Scripting Runtime
wasAnimated = true --you'll need to set this according to the situation, its true now for example's sake
ResetDance = function()
if wasAnimated then
thisPlayer.PlayCustomAnimation(theAnimation)
end
end
thisPlayer.OnAvatarReload(ResetDance)Space.Scene.PlayerAvatar.SynchroniseState()Space.Scene.PlayerAvatar.StartFly()--the below script teleports the player to a sky location after he clicks
--but then immediately puts the character in fly mode so they don't fall back down
--(Example: Sky exhibit)
thisGameObject = Space.Host.ExecutingObject
OnClick = function()
Space.Scene.PlayerAvatar.Teleport(Vector.New(0,10,0))
Space.Scene.PlayerAvatar.StartFly()
end
thisGameObject.AddClickable()
thisGameObject.Clickable.Tooltip = "Click me to view our sky exhibit!"
thisGameObject.Clickable.OnClick(OnClick) Space.Scene.PlayerAvatar.EndFly()--the below script teleports a player flying in the sky back to the ground
--and then ends fly mode by switching to Idle so they remain standing
--(Example: Going back down to ground from Sky exhibit)
thisGameObject = Space.Host.ExecutingObject
OnClick = function()
Space.Scene.PlayerAvatar.Teleport(Vector.New(0,0,0))
Space.Scene.PlayerAvatar.EndFly()
end
thisGameObject.AddClickable()
thisGameObject.Clickable.Tooltip = "Click me to go back to the ground!"
thisGameObject.Clickable.OnClick(OnClick) avatar=Space.Scene.PlayerAvatar
Space.Log(avatar.BlockJump)
avatar.OnAvatarSkeletonReload(function ()
Space.Log(avatar.OutfitID)
end)--this script ensures the avatar is still animating after their avatar's skeleton gets reloaded
thisPlayer = Space.Scene.PlayerAvatar
theAnimation = Space.GetResource("The Animation") --add animation to resources in Scripting Runtime
wasAnimated = true --you'll need to set this according to the situation, its true now for example's sake
ResetDance = function()
if wasAnimated then
thisPlayer.PlayCustomAnimation(theAnimation)
end
end
thisPlayer.OnAvatarSkeletonReload(ResetDance)timeUntilNextEvent = Space.Scene.PlayerAvatar.TeleportToNextEvent()
--or
timeUntilNextEvent = Space.Scene.PlayerAvatar.TeleportToNextEvent(500)playerUsername = Space.Scene.PlayerAvatar.Username --this script, once clicked, will get all avatars in the scene
--and print their Username(including self)
--(Example: scoreboards/radars/scanners/game machines)
thisGameObject = Space.Host.ExecutingObject
OnClick = function()
allAvatars = Space.Scene.AllAvatars
for var=1, #allAvatars do
local Username = allAvatars[var].Username
Space.Log("Username: " .. Username)
end
end
thisGameObject.AddClickable()
thisGameObject.Clickable.Tooltip = "Click to print all avatars' Username"
thisGameObject.Clickable.OnClick(OnClick) playerDisplayName = Space.Scene.PlayerAvatar.DisplayNameplayerTitle = Space.Scene.PlayerAvatar.Title --this script, once clicked, will get all avatars in the scene
--and print their Title and Username(including self)
thisGameObject = Space.Host.ExecutingObject
OnClick = function()
allAvatars = Space.Scene.AllAvatars
for var=1, #allAvatars do
local Username = allAvatars[var].Username
local Title = allAvatars[var].Title
Space.Log(Title .. " " .. Username)
end
end
thisGameObject.AddClickable()
thisGameObject.Clickable.Tooltip = "Click to print all avatars' Titles and Username"
thisGameObject.Clickable.OnClick(OnClick)playerJobTitle = Space.Scene.PlayerAvatar.OrgTitleplayerCompanyName = Space.Scene.PlayerAvatar.OrgNameplayerID = Space.Scene.PlayerAvatar.ID--this script, once clicked, will get all avatars in the scene
--and print their ID(including self)
--(Example: scoreboards/radars/scanners/game machines)
thisGameObject = Space.Host.ExecutingObject
OnClick = function()
allAvatars = Space.Scene.AllAvatars
for var=1, #allAvatars do
local ID = allAvatars[var].ID
Space.Log("ID: " .. ID)
end
end
thisGameObject.AddClickable()
thisGameObject.Clickable.Tooltip = "Click to print all avatars' ID"
thisGameObject.Clickable.OnClick(OnClick) isAttached = Space.Scene.PlayerAvatar.IsAttachedSpace.Scene.PlayerAvatar.MovementSpeed = 20 --the below script makes the object give the player triple movement speed
--once it's clicked, and then returns them to original speed after 10 seconds
--(Example: Triple Speed Powerup (avatar running race))
thisGameObject = Space.Host.ExecutingObject
TripleSpeedCoroutine = function()
local originalSpeed = Space.Scene.PlayerAvatar.MovementSpeed
Space.Scene.PlayerAvatar.MovementSpeed = originalSpeed * 3
coroutine.yield(10)
Space.Scene.PlayerAvatar.MovementSpeed = originalSpeed
end
OnClick = function()
Space.Host.StartCoroutine(TripleSpeedCoroutine)
end
thisGameObject.AddClickable()
thisGameObject.Clickable.Tooltip = "Triple Speed Powerup!"
thisGameObject.Clickable.OnClick(OnClick) Space.Scene.PlayerAvatar.JumpHeight = 20 --the below script makes the object give the player triple jump height
--once it's clicked, and then returns them to original jump height after 10 seconds
--(Example: Triple Jump Height Powerup )
thisGameObject = Space.Host.ExecutingObject
originalJumpHeight = Space.Scene.PlayerAvatar.JumpHeight
TripleJumpHeightCoroutine = function()
Space.Scene.PlayerAvatar.JumpHeight = originalJumpHeight * 3
coroutine.yield(10)
Space.Scene.PlayerAvatar.JumpHeight = originalJumpHeight
end
OnClick = function()
Space.Host.StartCoroutine(TripleJumpHeightCoroutine)
end
thisGameObject.AddClickable()
thisGameObject.Clickable.Tooltip = "Triple JumpHeight Powerup!"
thisGameObject.Clickable.OnClick(OnClick) isGuest = Space.Scene.PlayerAvatar.Guest--this script will make this object non-clickable for guest players
thisObject = Space.Host.ExecutingObject
thisPlayer = Space.Scene.PlayerAvatar
OnClick = function()
Space.Log("Do Something")
end
if not thisPlayer.Guest then --if player is not guest
thisObject.AddClickable()
thisObject.Clickable.OnClick(OnClick)
endavOutfit = Space.Scene.PlayerAvatar.OutfitIDisLoaded = Space.Scene.PlayerAvatar.Loaded--this script will wait for a joining avatar to load first before making it play an animation
--(otherwise that animation may be reset if played before load is complete)
NewJoinAnimation = Space.GetResource("The Animation")
OnPlayerJoin = function(NewAvatar)
Space.Host.StartCoroutine(function()
while not NewAvatar.Loaded do coroutine.yield(0) end --makes it wait
Space.Log("yes")
NewAvatar.PlayCustomAnimation(NewJoinAnimation) --at this point Loaded is True
end)
end
Space.Scene.OnPlayerJoin(OnPlayerJoin)playerGender = Space.Scene.PlayerAvatar.GenderlockObject = Space.Scene.PlayerAvatar.LockObjectavSkeleton = Space.Scene.PlayerAvatar.Skeleton--clicking this object will replace your avatar's animator controller (found on the skeleton)
thisObject = Space.Host.ExecutingObject
thisPlayer = Space.Scene.PlayerAvatar
customController = Space.GetResource("animcont")
OnClick = function()
thisPlayer.Skeleton.Animator.Controller = customController
end
thisObject.AddClickable()
thisObject.Clickable.OnClick(OnClick)Space.Scene.PlayerAvatar.BlockMovement = true --the below script makes this object a boundary area where any user entering it
--will be blocked from movement for 20 seconds, then the object will release controls and
--destroy itself after that
--(Example: freezing trap)
--[This object's collider needs to be set as IsTrigger (Please read about OnTriggerStart for troubleshooting)]
thisGameObject = Space.Host.ExecutingObject
FrozenTime = 0.0
OnTriggerStart = function(TriggerStarter)
if TriggerStarter.Root.Avatar ~= nil then
if TriggerStarter.Root.Avatar.Username == Space.Scene.PlayerAvatar.Username then
Space.Scene.PlayerAvatar.BlockMovement = true
end
end
end
OnTriggerStay = function(TriggerStayer)
if TriggerStayer.Root.Avatar ~= nil then
if TriggerStayer.Root.Avatar.Username == Space.Scene.PlayerAvatar.Username then
FrozenTime = FrozenTime + Space.DeltaTime
if FrozenTime > 20 then
Space.Scene.PlayerAvatar.BlockMovement = false
thisGameObject.Destroy()
end
end
end
end
thisGameObject.SubscribeToEvents()
thisGameObject.OnTriggerStart(OnTriggerStart)
thisGameObject.OnTriggerStay(OnTriggerStay)Space.Scene.PlayerAvatar.BlockRun = true--this script will block a player's run ability when entering trigger collider and release it when leaving
--[Requires this object to have a "Trigger" collider]
thisObject = Space.Host.ExecutingObject
thisPlayer = Space.Scene.PlayerAvatar
OTS = function(gameObject)
if gameObject.Avatar ~= nil and thisPlayer == gameObject.Avatar then
thisPlayer.BlockRun = true
end
end
OTE = function(gameObject)
if gameObject.Avatar ~= nil and thisPlayer == gameObject.Avatar then
thisPlayer.BlockRun = false
end
end
thisObject.OnTriggerStart(OTS)
thisObject.OnTriggerExit(OTE)Space.Scene.PlayerAvatar.BlockFly = true--this script will block a player's fly ability when entering trigger collider and release it when leaving
--[Requires this object to have a "Trigger" collider]
thisObject = Space.Host.ExecutingObject
thisPlayer = Space.Scene.PlayerAvatar
OTS = function(gameObject)
if gameObject.Avatar ~= nil and thisPlayer == gameObject.Avatar then
thisPlayer.BlockFly = true
end
end
OTE = function(gameObject)
if gameObject.Avatar ~= nil and thisPlayer == gameObject.Avatar then
thisPlayer.BlockFly = false
end
end
thisObject.OnTriggerStart(OTS)
thisObject.OnTriggerExit(OTE)Space.Scene.PlayerAvatar.BlockCrouch = true--this script will block a player's crouch ability when entering trigger collider and release it when leaving
--[Requires this object to have a "Trigger" collider]
thisObject = Space.Host.ExecutingObject
thisPlayer = Space.Scene.PlayerAvatar
OTS = function(gameObject)
if gameObject.Avatar ~= nil and thisPlayer == gameObject.Avatar then
thisPlayer.BlockCrouch = true
end
end
OTE = function(gameObject)
if gameObject.Avatar ~= nil and thisPlayer == gameObject.Avatar then
thisPlayer.BlockCrouch = false
end
end
thisObject.OnTriggerStart(OTS)
thisObject.OnTriggerExit(OTE)Space.Scene.PlayerAvatar.BlockJump = true--this script will block a player's jump ability when entering trigger collider and release it when leaving
--[Requires this object to have a "Trigger" collider]
thisObject = Space.Host.ExecutingObject
thisPlayer = Space.Scene.PlayerAvatar
OTS = function(gameObject)
if gameObject.Avatar ~= nil and thisPlayer == gameObject.Avatar then
thisPlayer.BlockJump= true
end
end
OTE = function(gameObject)
if gameObject.Avatar ~= nil and thisPlayer == gameObject.Avatar then
thisPlayer.BlockJump= false
end
end
thisObject.OnTriggerStart(OTS)
thisObject.OnTriggerExit(OTE)isGrounded = Space.Scene.PlayerAvatar.IsGroundedplayerObject = Space.Scene.PlayerAvatar.GameObject--Clicking this object will teleport you 2 units forward and make you face the opposite way
thisObject = Space.Host.ExecutingObject
thisPlayer = Space.Scene.PlayerAvatar
OnClick = function()
local targetPos = thisPlayer.GameObject.WorldPosition + (thisPlayer.GameObject.Forward * 2)
local targetRot = thisPlayer.GameObject.WorldRotation * Quaternion.AngleAxis(Vector.Up, 180)
thisPlayer.Teleport(targetPos, targetRot)
end
thisObject.AddClickable()
thisObject.Clickable.OnClick(OnClick)static float Random ()
Returns a random float between 0 and 1 (inclusive)
static float RandomRange (float min, float max)
Returns a random float between min and max (inclusive)
static int RandomInteger (int min, int max)
Returns a random float between min (inclusive) and max (exclusive)
static float Abs (float v) static int Abs (int v)
Returns the absolute value of 'val'
static float Acos (float v)
Returns the arc cosine value of 'val'
static bool Approximately (float a, float b)
True if the difference between a and b is less than epsilon
static float Asin (float v)
Returns the arc sine value of 'val'
static float Atan (float v)
Returns the arc tangent value of 'val'
static float Atan2 (float y, float x)
Returns the arc tangent of y/x
static int Ceil (float v)
Returns the ceil value of 'val' as an integer
static float Clamp (float v, float min, float max)
Clamps val between min and max, and returns the result
static float Clamp01 (float v)
Clamps val between 0 and 1, and returns the result
static int ClosestPowerOfTwo (int v)
Returns the closest power of two to val
static float Cos (float v)
Returns the cosine of val
static float DeltaAngle (float current, float target)
Returns the difference in degrees between two values (e.g. 350' and 17' returns 27')
static float Exp (float v)
Returns e raised to val power.
static int Floor (float v)
Returns floor of val, converted to an int
static float GammaToLinearSpace (float v)
Converts a colour value from Gamma to Linear Space (Pow 2.2)
static float InverseLerp (float a, float b, float value)
Returns the percentage between a and b that 'val' is on a line (opposite of Lerp)
static bool IsPowerOfTwo (int v)
Returns true if val is a power of two
static float Lerp (float a, float b, float v)
Interpolates between 'a' and 'b' based on 'val', assuming 'val' is between 0 and 1
static float LerpAngle (float a, float b, float v)
Interpolates between angles 'a' and 'b' based on 'val', assuming 'val' is between 0 and 1
static float LerpUnclamped (float a, float b, float v)
Interpolates between 'a' and 'b' based on 'val', assuming 'val' is between 0 and 1, but unbounded (allowing higher/lower values)
static float LinearToGammaSpace (float v)
Converts a colour value from Linear to Gamma Space (Pow 1/2.2)
static float Log (float v) static float Log (float v, float p)
Returns the natural logarithm for 'val'
static float Log10 (float v)
Returns the Log10 value for 'val'
static float Max (float a, float b)
Returns higher of 'a' or 'b'
static float Min (float a, float b)
Returns lower of 'a' or 'b'
static float MoveTowards (float value, float target, float delta)
Move value to target, but by no more than delta
static float MoveTowardsAngle (float value, float target, float delta)
Move angle value to target, but by no more than delta
static int NextPowerOfTwo (int v)
Return the next power of two larger or equal to val
static float PerlinNoise (float x, float y)
Return 2D Perlin noise for coordinates x and y
static float PingPong (float t, float length)
Return a value between 0 and length that oscillates upwards and back based on the position of 'val'
static float Pow (float value, float pow)
Return x raised to y power
static float Repeat (float value, float length)
Return a value between 0 and length that returns to 0 after exceeding length based on 'val'
static int Round (float value)
Returns the nearest integer value to val
static float Sign (float value)
Returns either 1 or -1 based on the sign of 'val'
static float Sin (float value)
Returns the sine of val
static float SmoothStep (float from, float to, float t)
Similar to Lerp but moves slowly closer to the edges ('Spherical Lerp')
static float Sqrt (float value)
Returns the square root of val
static float Tan (float value)
Returns the tangent value of 'val'
static readonly float Pi = 3.14159265358979f
Returns the constant value of Î .
static int (int v)
static float (float v)
static float (float current, float target)
static float (float v)
static int (float v)
static float (float v)
static float (float a, float b, float value)
static bool (int v)
static float (float a, float b, float v)
static float (float a, float b, float v)
static float (float a, float b, float v)
static float (float v)
static float (float v) static float (float v, float p)
static float (float v)
static float (float a, float b)
static float (float a, float b)
static float (float value, float target, float delta)
static float (float value, float target, float delta)
static int (int v)
static float (float x, float y)
static float (float t, float length)
static float (float value, float pow)
static float (float value, float length)
static int (float value)
static float (float value)
static float (float value)
static float (float from, float to, float t)
static float (float value)
static float (float value)
static float Random ()
static float RandomRange (float min, float max)
static int RandomInteger (int min, int max)
static float Acos (float v)
static bool Approximately (float a, float b)
static float Asin (float v)
static float Atan (float v)
static float Atan2 (float y, float x)
static int Ceil (float v)
static float Clamp (float v, float min, float max)
static readonly float Pi****
static float (float v)
local randomNumber = Space.Math.Random();
Space.Log(randomNumber);
-- prints 0.689094245433807local min = 100.0;
local max = 500.0;
local randomNumber = Space.Math.RandomRange(min, max );
Space.Log(randomNumber);
-- prints 0206.659149169922local min = 50;
local max = 75;
local randomInteger = Space.Math.RandomInteger(min, max);
Space.Log(randomInteger);
-- prints 52local value = -4.2
local absoluteNum = Space.Math.Abs(value);
Space.Log(absoluteNum);
-- prints 4 [BUG] should be 4.2local value = 0.5;
local arcCosine = Space.Math.Acos(value);
Space.Log(arcCosine);
-- prints 1.04719758033752 (radians) which is 60 degreeslocal a = 5.0;
local b = 5;
local approx1 = Space.Math.Approximately(a, b);
Space.Log(approx1);
-- prints true
local a = 5.01;
local b = 5.0;
local approx2 = Space.Math.Approximately(a, b);
Space.Log(approx2);
-- prints false
local a = 5.01;
local b = 5.0;
local approx3 = Space.Math.Approximately(a, b);
Space.Log(approx3);
-- prints falselocal value = 0.5;
local arcSine = Space.Math.Asin(value);
Space.Log(arcSine);
-- prints 0.523598790168762 (radians) which is 30 degreeslocal value = 1.732050808;
local arcTangent = Space.Math.Atan(value);
Space.Log(arcTangent);
-- prints 1.04719758033752 (radians) which is 60 degreeslocal x = 0.5;
local y = 0.5;
local arcTangent = Space.Math.Atan2(y, x);
Space.Log(arcTangent);
-- prints 0.785398185253143Space.Log(Space.Math.Ceil(4.0));
-- prints 4
Space.Log(Space.Math.Ceil(4.2));
-- prints 5
Space.Log(Space.Math.Ceil(-4.2));
-- prints -4local value = 100.0;
local min = 20.0;
local max = 82.0;
local clampedValue = Space.Math.Clamp(value, min, max);
Space.Log(clampedValue);
-- prints 82local value = -1.0;
local clampedValue = Space.Math.Clamp01(value);
Space.Log(clampedValue);
-- prints 0local value = 33;
local powerOfTwo = Space.Math.ClosestPowerOfTwo(value);
Space.Log(powerOfTwo);
-- prints 32local angle = 1.04719758033752; -- converts to 60 degrees
local cosine = Space.Math.Cos(angle);
Space.Log(cosine);
-- prints 0.499999970197678
local angle2 = Space.Math.Pi/3; -- converts to 60 degrees
local cosine2 = Space.Math.Cos(angle2);
Space.Log(cosine2);
-- prints 0.499999970197678Space.Log(Space.Math.DeltaAngle(350.0, 17.0));
-- prints 27Space.Log(Space.Math.Exp(3.0));
-- prints 20.0855369567871Space.Log(Space.Math.Floor(4.0));
-- prints 4
Space.Log(Space.Math.Floor(4.2));
-- prints 4
Space.Log(Space.Math.Floor(-4.2));
-- prints -5Space.Log(Space.Math.GammaToLinearSpace(0.5));
-- prints 0.214041143655777local sliderStart = 0.0;
local sliderStop = 100.0;
local currentSliderPos = 75.0;
local percentage = Space.Math.InverseLerp(sliderStart, sliderStop, currentSliderPos);
Space.Log(percentage);
-- prints 0.75Space.Log(Space.Math.IsPowerOfTwo(55));
-- prints False
Space.Log(Space.Math.IsPowerOfTwo(32));
-- prints Truelocal sliderStart = 0.0;
local sliderStop = 100.0;
local percentage = 0.75;
local currentSliderPos = Space.Math.Lerp(sliderStart, sliderStop, percentage);
Space.Log(currentSliderPos);
-- prints 75local sliderStartAngle = 0.0;
local sliderStopAngle = Space.Math.Pi;-- 180 degrees
local percentage = 0.50;
local currentSliderPos = Space.Math.LerpAngle(sliderStartAngle, sliderStopAngle, percentage);
Space.Log(currentSliderPos);
-- prints 1.57079637050629 (90 degrees)local sliderStart = 0.0;
local sliderStop = 100.0;
local percentage = 2.0;
local currentSliderPos = Space.Math.LerpUnclamped(sliderStart, sliderStop, percentage);
Space.Log(currentSliderPos);
-- prints 200Space.Log(Space.Math.LinearToGammaSpace(0.214041143655777));
-- prints 0.5Space.Log(Space.Math.Log(30.0));
-- prints 3.40119743347168
Space.Log(Space.Math.Log(4.0, 2.0));
-- prints 2Space.Log(Space.Math.Log10(100.0));
-- prints 2Space.Log(Space.Math.Max(20.0, 100.0));
-- prints 100Space.Log(Space.Math.Min(20.0, 100.0));
-- prints 20local sliderStart = 5.0;
local sliderStop = 10.0;
local deltaChange = 1.0;
local currentSliderPos = Space.Math.MoveTowards(sliderStart, sliderStop, deltaChange);
Space.Log(currentSliderPos);
-- prints 6 (moves forward 1)
local sliderStart = 5.0;
local sliderStop = 10.0;
local deltaChange = 7.0;
local currentSliderPos = Space.Math.MoveTowards(sliderStart, sliderStop, deltaChange);
Space.Log(currentSliderPos); -- prints 10 (caps out at at the target value)
-- NOTE: Use negative delta to move away from target.local sliderStartAngle = Space.Math.Pi/2; -- 90 degrees
local sliderStopAngle = Space.Math.Pi; -- 180 degrees
local deltaChange = Space.Math.Pi/6; -- 30 degrees
local currentSliderPos = Space.Math.MoveTowardsAngle(sliderStartAngle, sliderStopAngle, deltaChange);
Space.Log(currentSliderPos);
-- prints 2.09439516067505 (moves forward 30 degrees to 120 degrees)
-- NOTE: Add 180 degrees (Space.Math.Pi) to move away from target.Space.Log(Space.Math.NextPowerOfTwo(16));
-- prints 16
Space.Log(Space.Math.NextPowerOfTwo(17));
-- prints 32-- Lua Translation of Unity C# Documentation
local ball = Space.Host.ExecutingObject;
ball.SubscribeToEvents();
-- animates this object to move upwards on the y axis with slight random movement
local animateBall = function()
local heightScale = 0.1; -- controls speed of movement
local xScale = 1.0; -- shifts x position on perlin noise plane
local height = heightScale * Space.Math.PerlinNoise(Space.Time * xScale, 0.0);
local pos = ball.LocalPosition;
pos.y = pos.y + height;
ball.LocalPosition = pos;
Space.Log(pos.y);
end
ball.OnUpdate(animateBall);
-- NOTE: If you need a guaranteed range of [0,1], make sure to clamp the value with Space.Math.Clamp01.--[[ In this example, if you traced the output of Space.Math.PingPong(value, length),
the return values would cycle forward through the range [0,5] then cycle backwards through the range [5,0] in order. --]]
local ball = Space.Host.ExecutingObject;
local originalPos = ball.LocalPosition;
ball.SubscribeToEvents();
-- The ball object oscillates back and forth on the x-axis.
local animateBall = function()
local value = Space.Time;
local length = 5.0;
local newPos = Vector.New(Space.Math.PingPong(value, length) + originalPos.x, originalPos.y, originalPos.z);
ball.LocalPosition = newPos;
end
ball.OnUpdate(animateBall);Space.Log(Space.Math.Pow(2, 4));
-- prints 16--[[ In this example, if you traced the output of Space.Math.Repeat(value, length),
the return values would cycle forward through the range [0,5]. The cycle is repeated again from 0.--]]
local ball = Space.Host.ExecutingObject;
local originalPos = ball.LocalPosition;
ball.SubscribeToEvents();
-- The ball object moves forward on the x-axis.
-- Then, it repeats the same motion again from the beginning.
local animateBall = function()
local value = Space.Time;
local length = 5.0;
local newPos = Vector.New(Space.Math.Repeat(value, length) + originalPos.x, originalPos.y, originalPos.z);
ball.LocalPosition = newPos;
end
ball.OnUpdate(animateBall);Space.Log(Space.Math.Round(4.0));
-- prints 4
Space.Log(Space.Math.Round(4.2));
-- prints 4
Space.Log(Space.Math.Round(4.5));
-- prints 4
Space.Log(Space.Math.Round(4.55));
-- prints 5
Space.Log(Space.Math.Round(4.8));
-- prints 5
Space.Log(Space.Math.Round(-4.2));
-- prints -4
Space.Log(Space.Math.Round(-4.8));
-- prints -5Space.Log(Space.Math.Sign(4.2));
-- prints 1
Space.Log(Space.Math.Sign(-4.2));
-- prints -1local angle = 1.04719758033752; -- converts to 60 degrees
local sine = Space.Math.Sin(angle);
Space.Log(sine);
-- prints 0.866025447845459
local angle2 = Space.Math.Pi/3; -- converts to 60 degrees
local sine2 = Space.Math.Sin(angle2);
Space.Log(sine2);
-- prints 0.866025447845459-- Lua Translation of Unity C# Documentation
--[[ In this example, Space.Math.SmoothStep(min, max, time) returns values in the range [1,10] in order.
As values approach 10, the interpolation slows down. --]]
local ball = Space.Host.ExecutingObject;
local originalPos = ball.LocalPosition;
local min = 1.0;
local max = 10.0;
local duration = 5.0; --lower value to speed up; raise to slow down
local startTime;
ball.SubscribeToEvents();
local initStartTime = function()
startTime = Space.Time;
end
-- The ball jumps to min + originalPos, then it moves towards
-- max + originalPos while slowing down at the end.
local animateBall = function()
local time = (Space.Time - startTime) / duration;
local newPos = Vector.New(Space.Math.SmoothStep(min, max, time)
+ originalPos.x, originalPos.y, originalPos.z);
ball.LocalPosition = newPos;
end
ball.OnStart(initStartTime);
ball.OnUpdate(animateBall);Space.Log(Space.Math.Sqrt(16));
-- prints 4
Space.Log(Space.Math.Sqrt(-16));
-- prints NaNlocal angle = 1.04719758033752; -- converts to 60 degrees
local tangent = Space.Math.Tan(angle);
Space.Log(tangent);
-- prints 1.73205089569092
local angle2 = Space.Math.Pi/3; -- converts to 60 degrees
local tangent2 = Space.Math.Tan(angle2);
Space.Log(tangent2);
-- prints 1.73205089569092local angle = 1.04719758033752; -- converts to 60 degrees
local tangent = Space.Math.Tan(angle);
Space.Log(tangent);
-- prints 1.73205089569092
local angle2 = Space.Math.Pi/3; -- converts to 60 degrees
local tangent2 = Space.Math.Tan(angle2);
Space.Log(tangent2);
-- prints 1.73205089569092local angle = 1.04719758033752; -- converts to 60 degrees
local tangent = Space.Math.Tan(angle);
Space.Log(tangent);
-- prints 1.73205089569092
local angle2 = Space.Math.Pi/3; -- converts to 60 degrees
local tangent2 = Space.Math.Tan(angle2);
Space.Log(tangent2);
-- prints 1.73205089569092pi = Space.Math.Pivoid SubscribeToEvents ()
Causes this script to start listening to events on the object.
void SetSiblingIndex (int newIndex)
Sets the sibling index.
Use this to change the sibling index of the GameObject. If a GameObject shares a parent with other GameObjects and are on the same level (i.e. they share the same direct parent), these GameObjects are known as siblings. The sibling index shows where each GameObject sits in this sibling hierarchy.
Use SetSiblingIndex to change the GameObject’s place in this hierarchy. When the sibling index of a GameObject is changed, its order in the Hierarchy window will also change.
void SetAsFirstSibling ()
This GameObject becomes the first Sibling
void SetAsLastSibling ()
This GameObject becomes the last Sibling
SGameObject Duplicate ()
Copies the object and returns a reference to the copy. Equivalent to calling Instantiate() in Unity
SGameObject Instantiate ()
Copy of Duplicate() for convenience
AddHingeJoint ()
Adds a Hinge Joint component to this Game Object and returns its reference
AddLight ()
Adds a Light component to the object.
AddAnimator ()
Adds an Animator component to this Game Object and returns its reference
AddAudioSource ()
Adds an AudioSource component to the object.
AddClickable ()
Adds a Clickable component to the object.
GetScript (string name)
Returns a Scripting Runtime component attached to this object by Component Name, or nil if none exist
List< > GetScriptsInChildren (string name, bool includeInactive=false)
Returns Scripting Runtime components attached to this object by Component Name or its children
GetScriptInChildren (string name, bool includeInactive=false)
Returns a Scripting Runtime component attached to this object or its children by Component Name, or nil if none exist
GetScriptInParent (string name)
Returns a Scripting Runtime component attached to this object or its parents by Component Name, or nil if none exist
GetEvents (string name)
Function Description
List< > GetAllEventsInChildren (string name, bool includeInactive=false)
Function Description
GetEventsInChildren (string name, bool includeInactive=false)
Function Description
GetEventsInParent (string name)
Function Description
GetResources (string name)
Function Description
List< > GetAllResourcesInChildren (string name, bool includeInactive=false)
Function Description
GetResourcesInChildren (string name, bool includeInactive=false)
Function Description
GetResourcesInParent (string name)
Function Description
GetData (string name)
Returns a Scripting Data component attached to this object by Component Name, or nil if none exist
List< > GetAllDataInChildren (string name, bool includeInactive=false)
Returns Scripting Data components attached to this object by Component Name or its children
GetDataInChildren (string name, bool includeInactive=false)
Returns a Scripting Data component attached to this object or its children by Component Name, or nil if none exist
GetDataInParent (string name)
Returns a Scripting Data component attached to this object or its parents by Component Name, or nil if none exist
AddRigidbody ()
Adds a Rigidbody component to the object.
AddNavMeshAgent ()
Adds a NavMeshAgent component to the object.
AddSeat ()
Adds a Seat component to the object.
void OnAwake (Closure e)
Binds a event to the Awake() event.
void OnStart (Closure e)
Binds a event to the Start() event.
void OnEnable (Closure e)
Binds a event to the OnEnable() event.
void OnDisable (Closure e)
Binds a event to the OnDisable() event.
void OnFixedUpdate (Closure e)
Binds a event to the OnFixedUpdate() event.
void OnLateUpdate (Closure e)
Binds a event to the OnLateUpdate() event.
void OnTriggerStart (Action< SGameObject > e) void OnTriggerStart (Closure e)
When a GameObject collides with another GameObject, Unity calls OnTriggerEnter.
OnTriggerEnter happens on the FixedUpdate function when two GameObjects collide. The Colliders involved are not always at the point of initial contact.
Note: Both GameObjects must contain a Collider component. One must have Collider.isTrigger enabled, and contain a Rigidbody. If both GameObjects have Collider.isTrigger enabled, no collision happens. The same applies when both GameObjects do not have a Rigidbody component.
void OnTriggerStay (Action< SGameObject > e) void OnTriggerStay (Closure e)
OnTriggerStay is called almost all the frames for every Collider other that is touching the trigger. The function is on the physics timer so it won't necessarily run every frame.
This message is sent to the trigger and the collider that touches the trigger. Note that trigger events are only sent if one of the colliders also has a rigidbody attached. Trigger events will be sent to disabled MonoBehaviours, to allow enabling Behaviours in response to collisions.
void OnTriggerExit (Action< SGameObject > e) void OnTriggerExit (Closure e)
OnTriggerExit is called when the Collider other has stopped touching the trigger.
This message is sent to the trigger and the Collider that touches the trigger. Notes: Trigger events are only sent if one of the Colliders also has a Rigidbody attached. Trigger events will be sent to disabled MonoBehaviours, to allow enabling Behaviours in response to collisions. OnTriggerExit occurs on the FixedUpdate after the Colliders have stopped touching. The Colliders involved are not guaranteed to be at the point of initial separation.
void OnCollisionEnter (Action< SPhysicsHit > e) void OnCollisionEnter (Closure e)
OnCollisionEnter is called when this collider/rigidbody has begun touching another rigidbody/collider.
In contrast to , OnCollisionEnter is passed the class and not a Collider (GameObject). The SPhysicsHit class contains information, for example, about contact points and impact velocity. Notes: Collision events are only sent if one of the colliders also has a non-kinematic rigidbody attached. Collision events will be sent to disabled MonoBehaviours, to allow enabling Behaviours in response to collisions.
void OnCollisionStay (Action< > e) void OnCollisionStay (Closure e)
OnCollisionStay is called once per frame for every collider/rigidbody that is touching rigidbody/collider.
In contrast to , OnCollisionStay is passed the class and not a Collider (GameObject). The class contains information about contact points, impact velocity etc. If you don't use collisionInfo in the function, leave out the collisionInfo parameter as this avoids unneccessary calculations. Notes: Collision events are only sent if one of the colliders also has a non-kinematic rigidbody attached. Collision events will be sent to disabled MonoBehaviours, to allow enabling Behaviours in response to collisions. Collision stay events are not sent for sleeping Rigidbodies.
void OnCollisionExit (Action< > e) void OnCollisionExit (Closure e)
OnCollisionExit is called when this collider/rigidbody has stopped touching another rigidbody/collider.
In contrast to OnTriggerExit, OnCollisionExit is passed the SPhysicsHit class and not a Collider. The SPhysicsHit class contains information about contact points, impact velocity etc. If you don't use collisionInfo in the function, leave out the collisionInfo parameter as this avoids unneccessary calculations. Notes: Collision events are only sent if one of the colliders also has a non-kinematic rigidbody attached. Collision events will be sent to disabled MonoBehaviours, to allow enabling Behaviours in response to collisions.
void OnParticleCollision (Action< SGameObject > e) void OnParticleCollision (Closure e)
OnParticleCollision is called when a particle hits a Collider.
This can be used to apply damage to a GameObject when hit by particles.
This message is sent to scripts attached to Particle Systems and to the Collider that was hit.
When OnParticleCollision is invoked from a script attached to a GameObject with a Collider, the GameObject parameter represents the ParticleSystem. The Collider receives at most one message per Particle System that collided with it in any given frame even when the Particle System struck the Collider with multiple particles in the current frame.
When OnParticleCollision is invoked from a script attached to a ParticleSystem, the GameObject parameter represents a GameObject with an attached Collider struck by the ParticleSystem. The ParticleSystem receives at most one message per Collider that is struck.
Messages are only sent if you enable Send Collision Messages in the Inspector of the Particle System Collision module.
The OnParticleCollision can be a co-routine. Simply use the yield statement in the function.
void OnParticleTrigger (Closure e)
Binds a new event handler for the OnParticleTrigger event.
OnParticleTrigger event is called when any particles in a Particle System meet the conditions in the trigger module.
This can be used to kill or modify particles that are inside or outside a collision volume.
void OnUpdate (Closure e)
Binds a event to the OnUpdate() event.
void OnMouseDown (Closure e)
Binds a event to the OnMouseDown() event.
void OnApplicationQuit (Closure e)
Binds a new event handler for the On Application Quit event
bool CompareTag (string tag)
Function Description
void SetParent (SGameObject other, bool worldPositionStays=true)
Make this GameObject the child of GameObject 'other'
SGameObject Find (string name)
Find and return a reference to GameObject with name 'name'
SGameObject FindInChildren (string name)
Find and return a reference to GameObject with name 'name' including children
void Destroy ()
Schedules this object for deletion at the end of the frame
SComponent GetComponent (string name)
Depreciated
long Owner get
Returns the GameObject's Owner
int LocalID get
Returns the GameObject's Local ID
int InventoryID get
Return's the GameObject's InventoryID
bool HasStableID get
Returns true if GameObject has Stable ID
string? GlobalID get
Returns the global ID of the GameObject
bool Exists get
Does this object still exist in the scene (returns false if the object has been deleted via Destroy();)
HingeJoint get
Returns a HingeJoint component attached to this object, or nil if none exist
Light get
Returns a reference to a Light component on the object. Will return null if it does not exist.
ReflectionProbe get
Returns a ReflectionProbe component attached to this object, or nil if none exist
LightInChildget
Returns a Light component attached to this object or its children, or nil if none exist
LightInParent get
Returns a Light component attached to this object or it's parent, or nil if none exist
Animator get
Returns a reference to a Animator component on the object. Will return null if it does not exist.
Animation get
Returns an Animation component attached to this object, or nil if none exist Animation is a legacy component and should not be confused with Animator
CanvasGroup get
Returns Canvas Group component attached to this object, or nil if none exist
Audio get
Returns a reference to a AudioSource component on the object. Will return null if it does not exist.
Floor get
Returns a RoomFloor component attached to this object, or nil if none exist
VoiceZone get
Returns a VoiceZone component attached to this object, or nil if none exist
Browser get
Returns a reference to a BrowserSurface component on the object. Will return null if it does not exist.
Director get
Returns a PlayableDirector component attached to this object, or nil if none exist
Renderer get
Returns a reference to a Renderer component on the object. Will return null if it does not exist.
Vehicle get
Returns a Modular Vehicle component attached to this object, or nil if none exist
PostProcessVolume get
Returns a Post Process Volume component attached to this object, or nil if none exist
SAXModel Archimatix get
Returns a Archimatix Model ("AXModel" component) - or Nil if nothing exists
Clickable get
Returns a reference to a Clickable component on the object. Will return null if it does not exist.
EmbeddedVideo get
Returns an Embedded Video component attached to this object, or nil if none exist (may not work within editor)
Avatar get
A reference to an Avatar component on the GameObject.
AvatarAppearance get
Returns a AvatarAppearance component attached to this object, or nil if none exist
Script get
Returns a Scripting Runtime component attached to this object, or nil if none exist
StateMachine get
Returns a State Machine component attached to this object, or nil if none exist
Networking get
Returns a Simple Networking component attached to this object, or nil if none exists
Events get
Property Description
Resources get
Property Description
Data get
Returns a Scripting Data component attached to this object, or nil if none exist
Rigidbody get
Returns a reference to a Rigidbody component on the object. Will return null if it does not exist.
Collider get
Returns a reference to a Collider component on the object. Will return null if it does not exist.
BoxCollider get
Returns a Box Collider component attached to this object, or nil if none exist
SphereCollider get
Returns a Sphere Collider component attached to this object, or nil if none exist
CapsuleCollider get
Returns a Capsule Collider component attached to this object, or nil if none exist
WheelCollider get
Returns a WheelCollider component attached to this object, or nil if none exist
CharacterController get
Returns a Character Controller component attached to this object, or nil if none exist
AudioReactive get
Returns the first Audio Reactive component attached to this object, or nil if none exist
SAttachmentHelper AttachmentHelper get
Returns the first Attachment Helper component attached to this object, or nil if none exist
AudioReactiveAnimation get
Returns the first Audio Reactive Animation component attached to this object, or nil if none exist
AudioReactiveLight get
Returns the first Audio Reactive Light component attached to this object, or nil if none exist
AudioReactiveParticleSystem get
Returns the first Audio Reactive Particle System component attached to this object, or nil if none exist
AudioReactiveMaterial get
Returns the first Audio Reactive Material component attached to this object, or nil if none exist
AudioReactiveTransform get
Returns the first Audio Reactive Transform component attached to this object, or nil if none exist
TrailRenderer get
Returns a Trail Renderer component attached to this object, or nil if none exist
LineRenderer get
Returns a Line Renderer component attached to this object, or nil if none exist
UILayout get
Returns a Renderer component attached to this object, or nil if none exist
UIToggle get
Returns a Unity uGUI Toggle component attached to this object, or nil if none exist
UIDropdown get
Returns a Unity uGUI Dropdown component attached to this object, or nil if none exist
UIButton get
Returns a Unity uGUI Dropdown component attached to this object, or nil if none exist
UIText get
Returns a reference to a UI.Text component on the object. Will return null if it does not exist.
UISlider get
Returns a Unity uGUI Slider component attached to this object, or nil if none exist
UIScrollbar get
Returns a Unity uGUI Scrollbar component attached to this object, or nil if none exist
UICanvas get
Returns a Unity uGUI Canvas component attached to this object, or nil if none exist
UIImage get
Returns a Unity uGUI Image component attached to this object, or nil if none exist
UIRawImage get
Returns a Unity uGUI Text component attached to this object, or nil if none exist
UIInputField get
Returns a Unity uGUI Text component attached to this object, or nil if none exist
UIToolTipHint get
Property Description
Camera get
Property Description
VirtualCamera get
Returns a VirtualCamera component attached to this object, or nil if none exists
Cloth get
Returns a Cloth component attached to this object, or nil if none exists
MeshRenderer get
Returns a MeshRenderer component attached to this object, or nil if none exists
Furniture get
Returns a Furniture component attached to this object, or nil if none exists
NavMeshAgent get
Adds a NavMeshAgent component to the object.
NavMeshObstacle get
Returns a NavMeshObstacle component attached to this object, or nil if none exists
ParticleSystem get
Returns a ParticleSystem component attached to this object, or nil if none exists
RectTransform get
Returns a RectTransform component attached to this object, or nil if none exists
Seat get
Returns a reference to a Seat component on the object. Will return null if it does not exist.
SkinnedMeshRenderer get
Returns a SkinnedMeshRenderer component attached to this object, or nil if none exists
Radio get
Returns a SceneBackgroundMusic component attached to this object, or nil if none exists
Terrain get
Returns a Terrain component attached to this object, or nil if none exists
SAnalyticsEvent AnalyticsEvent get
Property Description
GraphicRaycaster get
Property Description
SContentSizeFitter ContentSizeFitter get
Property Description
bool Active get set
Is this object Active in the scene
bool ActiveSelf get set
Returns true if GameObject is Active (even if it's parent is not active)
int Layer get set
Gets/Sets the object onto a particular layer (0-31)
string Tag get
Gets this objects Tag
string Name get set
Gets/sets the name of this object
string? Moniker get set
Property Description
Parent get set
Gets/sets the parent GameObject of this object. Assign nil/null to set this as the root.
Root get
Gets the root of this object group - may be this object.
[] Children get
Returns the list of direct children of this object.
WorldPosition get set
Gets or sets the current position of this object relative to the scene
LocalPosition get set
Gets or sets the current position of this object relative to the objects parent, taking into account local position/scale/rotation
WorldRotation get set
Gets or sets the current rotation of this object relative to the scene
LocalRotation get set
Gets or sets the current rotation of this object relative to the parent object
LocalScale get set
Gets or sets the current scale of this object relative to the parent
WorldScale get
Gets the current scale of this object relative to the scene
Forward get
Returns the forward direction vector of this game object (blue arrow)
Up get
Returns the up direction vector of this game object (green arrow)
Right get
Returns the right direction vector of this game object (red arrow)
EventCalendar get
Returns an EventCalendar component attached to this object, or nil if none exists
name
string
Space.Host.ExecutingObject.SubscribeToEvents()Space.Host.ExecutingObject.SetSiblingIndex(2)Space.Host.ExecutingObject.SetAsFirstSibling()Space.Host.ExecutingObject.SetAsLastSibling()local copy = Space.Host.ExecutingObject.Duplicate()--this script will make this object, once clicked, duplicate itself, then the duplicate
--moves up and then duplicate itself again and the duplicate move down (total 3 vertically aligned)
--(Example: cells multiplying)
thisGameObject = Space.Host.ExecutingObject
OnClick = function()
local firstDuplicate = thisGameObject.Duplicate()
firstDuplicate.WorldPosition = firstDuplicate.WorldPosition + firstDuplicate.Up
local secondDuplicate = thisGameObject.Duplicate()
secondDuplicate.WorldPosition = secondDuplicate.WorldPosition - secondDuplicate.Up
end
thisGameObject.AddClickable()
thisGameObject.Clickable.Tooltip="Click to watch me multiply "
thisGameObject.Clickable.OnClick(OnClick)NewGameObject = Space.Host.ExecutingObject.Instantiate()--this script will make this object, once clicked, duplicate itself, then the duplicate
--moves up and then duplicate itself again and the duplicate move down (total 3 vertically aligned)
--(Example: cells multiplying)
thisGameObject = Space.Host.ExecutingObject
OnClick = function()
local firstDuplicate = thisGameObject.Instantiate()
firstDuplicate.WorldPosition = firstDuplicate.WorldPosition + firstDuplicate.Up
local secondDuplicate = thisGameObject.Instantiate()
secondDuplicate.WorldPosition = secondDuplicate.WorldPosition - secondDuplicate.Up
end
thisGameObject.AddClickable()
thisGameObject.Clickable.Tooltip="Click to watch me multiply "
thisGameObject.Clickable.OnClick(OnClick) NewHingeJoint = Space.Host.ExecutingObject.AddHingeJoint()--clicking this object will add a Hinge Joint component to it at runtime
thisObject = Space.Host.ExecutingObject
OnClick = function()
HJ = thisObject.AddHingeJoint()
end
thisObject.AddClickable()
thisObject.Clickable.OnClick(OnClick)newLightComponent = Space.Host.ExecutingObject.AddLight()NewAnimator = Space.Host.ExecutingObject.AddAnimator()--clicking this object will add an animator to it and controller at runtime
thisObject = Space.Host.ExecutingObject
theResource = Space.GetResource("An Animator Controller") -- add controller to resources in Scripting Runtime
OnClick = function()
Animator = thisObject.AddAnimator()
Animator.Controller = theResource
end
thisObject.AddClickable()
thisObject.Clickable.OnClick(OnClick)newAudioSourceComponent = Space.Host.ExecutingObject.AddAudioSource()newClikcableComponent = Space.Host.ExecutingObject.AddClickable()scriptingRuntime = Space.Host.ExecutingObject.GetScript("scriptingruntimecomponentname")tableScriptsInChildren = Space.Host.ExecutingObject.GetScriptsInChildren("scriptingruntimecomponentname",true)scriptingRuntimeInChildren = Space.Host.ExecutingObject.GetScriptInChildren("scriptingruntimecomponentname",true)scriptingRuntimeInParent = Space.Host.ExecutingObject.GetScript("scriptingruntimecomponentname")scriptingEvent = Space.Host.ExecutingObject.GetEvents('ScriptingEventsComponentName')tableScriptingEvent = Space.Host.ExecutingObject.GetAllEventsInChildrenscriptingEvent = Space.Host.ExecutingObject.GetEventsInChildren('ScriptingEventsComponentName')
--or
scriptingEvent = Space.Host.ExecutingObject.GetEventsInChildren('ScriptingEventsComponentName', true)scriptingEvent = Space.Host.ExecutingObject.GetEventsInParent('ScriptingEventsComponentName')Space.Host.ExecutingObject.GetResources('ResourcesComponentName')tableScriptingResources = Space.Host.ExecutingObject.GetAllResourcesInChildren('ScriptingResourcesComponentName')
--or
tableScriptingResources = Space.Host.ExecutingObject.GetAllResourcesInChildren('ScriptingResourcesComponentName', true)tableScriptingResources = Space.Host.ExecutingObject.GetResourcesInChildren('ScriptingResourcesComponentName')
--or
tableScriptingResources = Space.Host.ExecutingObject.GetResourcesInChildren('ScriptingResourcesComponentName', true)tableScriptingResources = Space.Host.ExecutingObject.GetResourcesInParent('ScriptingResourcesComponentName')scriptingData = Space.Host.ExecutingObject.GetData("scriptingdatacomponentname")tableScriptingDataInChildren = Space.Host.ExecutingObject.GetAllDataInChildren("scriptingdatacomponentname",true)scriptingDataInChildren = Space.Host.ExecutingObject.GetDataInChildren("scriptingdatacomponentname",true)scriptingDataInParent = Space.Host.ExecutingObject.GetDataInParent("scriptingdatacomponentname")newRigibodyComponent = Space.Host.ExecutingObject.AddRigidbody()newNavMeshAgentComponent = Space.Host.ExecutingObject.AddNavMeshAgent()newSeatComponent = Space.Host.ExecutingObject.AddSeat()function F()
Space.Log("bound")
end
Space.Host.ExecutingObject.OnAwake(F)function F()
Space.Log("bound")
end
Space.Host.ExecutingObject.OnStart(F)function F()
Space.Log("bound")
end
Space.Host.ExecutingObject.OnEnable(F)function F()
Space.Log("bound")
end
Space.Host.ExecutingObject.OnDisable(F)function F()
Space.Log("bound")
end
Space.Host.ExecutingObject.OnFixedUpdate(F)--this script will make this object move forward each physics frame
thisObject = Space.Host.ExecutingObject
OnFixedUpdate = function()
thisObject.WorldPosition = thisObject.WorldPosition + (thisObject.Forward * 0.01 )
--unlike OnUpdate we did not multiply by Space.DeltaTime
--because OnFixedUpdate executes at the same rate regardless
end
thisObject.OnFixedUpdate(OnFixedUpdate)function F()
Space.Log("bound")
end
Space.Host.ExecutingObject.OnLateUpdate(F)--this script will make this object move forward each frame
--but it will be last to move among other objects (read about OnLateUpdate)
--(example: camera movement)
thisObject = Space.Host.ExecutingObject
OnLateUpdate = function()
thisObject.WorldPosition = thisObject.WorldPosition + (thisObject.Forward * 0.01 * Space.DeltaTime)
--we multipy by Space.DeltaTime so that it behaves the same for all players
--even though they have different FPS (frames per second)
end
thisObject.OnLateUpdate(OnLateUpdate)this = Space.Host.ExecutingObject
OnTriggerStart = function(SGameObject)
Space.Log("Trigger Start")
end
this.OnTriggerStart (OnTriggerStart ) --the below scipt makes this object a boundary area where flying gets blocked
--while player is in it and flying is allowed once player leaves it
--(Example: No fly zone)
--[This object's collider needs to be set as IsTrigger (Please read about OnTriggerStart for troubleshooting)]
thisGameObject = Space.Host.ExecutingObject
OnTriggerStart = function(TriggerStarter)
if TriggerStarter.Root.Avatar ~= nil then
if TriggerStarter.Root.Avatar.Username == Space.Scene.PlayerAvatar.Username then
Space.Scene.PlayerAvatar.BlockFly = true
end
end
end
OnTriggerExit = function(TriggerExiter)
if TriggerExiter.Root.Avatar ~= nil then
if TriggerExiter.Root.Avatar.Username == Space.Scene.PlayerAvatar.Username then
Space.Scene.PlayerAvatar.BlockFly = false
end
end
end
thisGameObject.OnTriggerStart(OnTriggerStart)
thisGameObject.OnTriggerExit(OnTriggerExit) this = Space.Host.ExecutingObject
OnTriggerStay = function(SGameObject)
Space.Log("Trigger Stay")
end
this.OnTriggerStay(OnTriggerStay)--the below scipt makes this object a boundary area where any user entering it
--will be blocked from movement for 10 seconds, then the object will release controls and
--destry itself after that
--(Example: freezing trap)
--[This object's collider needs to be set as IsTrigger (Please read about OnTriggerStart for troubleshooting)]
thisGameObject = Space.Host.ExecutingObject
FrozenTime = 0.0
OnTriggerStart = function(TriggerStarter)
if TriggerStarter.Root.Avatar ~= nil then
if TriggerStarter.Root.Avatar.Username == Space.Scene.PlayerAvatar.Username then
Space.Scene.PlayerAvatar.BlockMovement = true
end
end
end
OnTriggerStay = function(TriggerStayer)
if TriggerStayer.Root.Avatar ~= nil then
if TriggerStayer.Root.Avatar.Username == Space.Scene.PlayerAvatar.Username then
FrozenTime = FrozenTime + Space.DeltaTime
if FrozenTime > 20 then
Space.Scene.PlayerAvatar.BlockMovement = false
thisGameObject.Destroy()
end
end
end
end
thisGameObject.OnTriggerStart(OnTriggerStart)
thisGameObject.OnTriggerStay(OnTriggerStay)this = Space.Host.ExecutingObject
OnTriggerExit = function(SGameObject)
Space.Log("Trigger Stay")
end
this.OnTriggerExit(OnTriggerExit)--the below scipt makes this object a boundary area where flying gets blocked
--while player is in it and flying is allowed once player leaves it
--(Example: No fly zone)
--[This object's collider needs to be set as IsTrigger (Please read about OnTriggerStart for troubleshooting)]
thisGameObject = Space.Host.ExecutingObject
OnTriggerStart = function(TriggerStarter)
if TriggerStarter.Root.Avatar ~= nil then
if TriggerStarter.Root.Avatar.Username == Space.Scene.PlayerAvatar.Username then
Space.Scene.PlayerAvatar.BlockFly = true
end
end
end
OnTriggerExit = function(TriggerExiter)
if TriggerExiter.Root.Avatar ~= nil then
if TriggerExiter.Root.Avatar.Username == Space.Scene.PlayerAvatar.Username then
Space.Scene.PlayerAvatar.BlockFly = false
end
end
end
thisGameObject.OnTriggerStart(OnTriggerStart)
thisGameObject.OnTriggerExit(OnTriggerExit)this = Space.Host.ExecutingObject
OnCollisionEnter = function(SPhysicsHit)
Space.Log("Collision Enter")
end
this.OnCollisionEnter(OnCollisionEnter) --this script will make this object delete itself if it collides with something
--(Example: grenade)
--[Make sure you add a rigibody to this object (read above about "collisions")
thisGameObject = Space.Host.ExecutingObject
OnCollisionEnter = function(SPhysicsHit)
thisGameObject.Destroy()
end
thisGameObject.OnCollisionEnter(OnCollisionEnter) this = Space.Host.ExecutingObject
OnCollisionStay = function(SPhysicsHit)
Space.Log("Collision Stay")
end
this.OnCollisionStay(OnCollisionStay) --this script will make this object delete itself if
--it is being touched for around 10 seconds
--(Example: a flag being captured)
--[Make sure this object has collider/rigidbody (read above about "collisions" for troubleshooting)]
thisGameObject = Space.Host.ExecutingObject
touchedTime = 0.0
OnCollisionStay = function(SPhysicsHit)
touchedTime = touchedTime + Space.DeltaTime
if touchedTime > 25 then
thisGameObject.Destroy()
end
end
thisGameObject.OnCollisionStay(OnCollisionStay) this = Space.Host.ExecutingObject
OnCollisionExit = function(SPhysicsHit)
Space.Log("Collision Exit")
end
this.OnCollisionExit(OnCollisionExit)--this script will make this object destroy itself when an object
--that collided with it exits the collission
--(Example: landmine)
--[Make sure you add a rigibody to this object (read above about "collisions")
thisGameObject = Space.Host.ExecutingObject
OnCollisionExit = function(SPhysicsHit)
thisGameObject.Destroy()
end
thisGameObject.OnCollisionExit(OnCollisionExit)this = Space.Host.ExecutingObject
OnParticleCollision = function(GameObject)
Space.Log("Particle Collision")
end
this.OnParticleCollision(OnParticleCollision)this = Space.Host.ExecutingObject
OnParticleTrigger = function(GameObject)
Space.Log("Particle Trigger Event")
end
this.OnParticleTrigger(OnParticleTrigger)function F()
Space.Log("bound")
end
Space.Host.ExecutingObject.OnUpdate(F)--this script will make this object move forward each frame
thisObject = Space.Host.ExecutingObject
OnUpdate = function()
thisObject.WorldPosition = thisObject.WorldPosition + (thisObject.Forward * 0.01 * Space.DeltaTime)
--we multipy by Space.DeltaTime so that it behaves the same for all players
--even though they have different FPS (frames per second)
end
thisObject.OnUpdate(OnUpdate)function F()
Space.Log("bound")
end
Space.Host.ExecutingObject.OnMouseDown(F)this = Space.Host.ExecutingObject
OnApplicationQuit = function()
Space.Log("Application Quit")
end
this.OnApplicationQuit(OnApplicationQuit)isSame = Space.Host.ExecutingObject.CompareTag('tagname')Space.Host.ExecutingObject.SetParent(otherObjectReference,true)--this script will set your avatar's "right hand" as parent of this object
--this way this object will be a child of your right hand and therefore move with it
--(Example: clicking on a gun to equip it)
thisGameObject = Space.Host.ExecutingObject
OnClick = function()
RightHand = Space.Scene.PlayerAvatar.FindBone("RightHand")
thisGameObject.SetParent(RightHand)
thisGameObject.LocalPosition = Vector.New(0,0,0) -- resetting position to match hand
end
thisGameObject.AddClickable()
thisGameObject.Clickable.Tooltip="Click to Equip "
thisGameObject.Clickable.OnClick(OnClick)FoundObject = Space.Host.ExecutingObject.Find("GameObject Name")FoundObjectInChildren = Space.Host.ExecutingObject.FindInChildren("GameObject Name")Space.Host.ExecutingObject.Destroy()Owner = Space.Host.ExecutingObject.OwnerLocalID = Space.Host.ExecutingObject.LocalIDInventoryID = Space.Host.ExecutingObject.InventoryIDHasStableID = Space.Host.ExecutingObject.HasStableIDGlobalID = Space.Host.ExecutingObject.GlobalIDdoesExist = Space.Host.ExecutingObject.ExistsHingeJoint = Space.Host.ExecutingObject.HingeJointnewLightComponent = Space.Host.ExecutingObject.LightReflectionProbe = Space.Host.ExecutingObject.ReflectionProbeLightInChild = Space.Host.ExecutingObject.LightInChildLightInParent = Space.Host.ExecutingObject.LightInParentanimatorComponent = Space.Host.ExecutingObject.AnimatorAnimation = Space.Host.ExecutingObject.AnimationCanvasGroup = Space.Host.ExecutingObject.CanvasGroupnewAudioComponent = Space.Host.ExecutingObject.AudioFloor = Space.Host.ExecutingObject.FloorVoiceZone = Space.Host.ExecutingObject.VoiceZonenewBrowserComponent = Space.Host.ExecutingObject.BrowserDirector = Space.Host.ExecutingObject.Directorrenderer = Space.Host.ExecutingObject.RendererVehicle = Space.Host.ExecutingObject.VehiclePostProcessVolume = Space.Host.ExecutingObject.PostProcessVolumeArchimatix = Space.Host.ExecutingObject.ArchimatixclickableComponent = Space.Host.ExecutingObject.ClickableEmbeddedVideo = Space.Host.ExecutingObject.EmbeddedVideoAvatar = Space.Host.ExecutingObject.AvatarAvatarAppearance = Space.Host.ExecutingObject.AvatarAppearanceScript = Space.Host.ExecutingObject.ScriptStateMachine = Space.Host.ExecutingObject.StateMachineSimpleNetworking = Space.Host.ExecutingObject.NetworkingeventsComponent = Space.Host.ExecutingObject.EventsresourcesComponent = Space.Host.ExecutingObject.ResourcesData = Space.Host.ExecutingObject.DatarigidbodyComponent = Space.Host.ExecutingObject.RigidbodycolliderComponent = Space.Host.ExecutingObject.ColliderBoxCollider = Space.Host.ExecutingObject.BoxColliderSphereCollider = Space.Host.ExecutingObject.SphereColliderCapsuleCollider = Space.Host.ExecutingObject.CapsuleColliderWheelCollider = Space.Host.ExecutingObject.WheelColliderCharacterController = Space.Host.ExecutingObject.CharacterControllerAudioReactive = Space.Host.ExecutingObject.AudioReactiveAttachmentHelper = Space.Host.ExecutingObject.AttachmentHelperAudioReactiveAnimation = Space.Host.ExecutingObject.AudioReactiveAnimationAudioReactiveLight = Space.Host.ExecutingObject.AudioReactiveLightAudioReactiveParticleSystem = Space.Host.ExecutingObject.AudioReactiveParticleSystemAudioReactiveMaterial = Space.Host.ExecutingObject.AudioReactiveMaterialAudioReactiveTransform = Space.Host.ExecutingObject.AudioReactiveTransformTrailRenderer = Space.Host.ExecutingObject.TrailRendererLineRenderer = Space.Host.ExecutingObject.LineRendererUILayout = Space.Host.ExecutingObject.UILayoutUIToggle = Space.Host.ExecutingObject.UIToggleUIDropdown = Space.Host.ExecutingObject.UIDropdownUIButton = Space.Host.ExecutingObject.UIButtonuitext = Space.Host.ExecutingObject.UIText UISlider = Space.Host.ExecutingObject.UISliderUIScrollbar = Space.Host.ExecutingObject.UIScrollbarUICanvas = Space.Host.ExecutingObject.UICanvasUIImage = Space.Host.ExecutingObject.UIImageUIRawImage = Space.Host.ExecutingObject.UIRawImageUIInputField = Space.Host.ExecutingObject.UIInputFieldtooltipHint = Space.Host.ExecutingObject.UIToolTipHintcamera = Space.Host.ExecutingObject.CameraVirtualCamera = Space.Host.ExecutingObject.VirtualCameraCloth = Space.Host.ExecutingObject.ClothMeshRenderer = Space.Host.ExecutingObject.MeshRendererFurniture = Space.Host.ExecutingObject.FurniturenavMeshAgent = Space.Host.ExecutingObject.AddNavMeshAgent()NavMeshObstacle = Space.Host.ExecutingObject.NavMeshObstacleParticleSystem = Space.Host.ExecutingObject.ParticleSystemRectTransform = Space.Host.ExecutingObject.RectTransformseatComponent = Space.Host.ExecutingObject.AddSeat()SkinnedMeshRenderer = Space.Host.ExecutingObject.SkinnedMeshRendererRadio = Space.Host.ExecutingObject.RadioTerrain = Space.Host.ExecutingObject.TerrainanalyticsEvent = Space.Host.ExecutingObject.AnalyticsEventgraphicRaycaster = Space.Host.ExecutingObject.GraphicRaycastercontentSzeFitter = Space.Host.ExecutingObject.ContentSizeFitterSpace.Host.ExecutingObject.Active = false--the below script will make this object become inactive
--after being being clicked
--(Example: picking up fruits)
thisGameObject = Space.Host.ExecutingObject
OnClick = function()
thisGameObject.Active = false
end
thisGameObject.AddClickable()
thisGameObject.Clickable.Tooltip="Pick me!"
thisGameObject.Clickable.OnClick(OnClick) Space.Host.ExecutingObject.ActiveSelf = falseSpace.Host.ExecutingObject.Layer = 21objectTag = Space.Host.ExecutingObject.TagSpace.Host.ExecutingObject.Name = 'Hello World!'Space.Host.ExecutingObject.Moniker = 'New Moniker'Space.Host.ExecutingObject.Parent = Space.Host.GetReference("TheOtherObject")objectRoot = Space.Host.ExecutingObject.RoottableChildren = Space.Host.ExecutingObject.ChildrenSpace.Host.ExecutingObject.WorldPosition = Vector.New(1,1,1)Space.Host.ExecutingObject.LocalPosition = Vector.New(1,1,1)Space.Host.ExecutingObject.WorldRotation = Quaternion.Euler(0,180,0)Space.Host.ExecutingObject.LocalRotation = Quaternion.Euler(0,180,0)Space.Host.ExecutingObject.LocalScale = Vector.New(2,2,2)worldScale = Space.Host.ExecutingObject.WorldScale vectorForward = Space.Host.ExecutingObject.ForwardvectorUp = Space.Host.ExecutingObject.UpvectorRight = Space.Host.ExecutingObject.RightEventCalendar = Space.Host.ExecutingObject.EventCalendar