wiki.sine.space | sinespace

Difference between revisions of "Scripting/SAvatar"

From wiki.sine.space
Jump to: navigation, search
(Members)
(Added simple examples to .Detach() .AttachTo() .Username .Title .ID .GameObject)
Line 2: Line 2:
  
 
=Members=
 
=Members=
{{ScriptFunction|string|Username|{ get; }|Returns the players current username (note: this can be changed by players for a small fee)}}
 
{{ScriptFunction|string|Title|{ get; }|Returns the players current title}}
 
{{ScriptFunction|long|ID|{ get; }|Returns the players user ID, please note if you store these, this is a 'long' value not a 'int'.}}
 
{{ScriptFunction|SGameObject|GameObject|{ get; }|Returns a reference to the players GameObject}}
 
  
{{ScriptFunction|void|Detach|();|Detaches the avatar from whatever it may be attached to (only works for the player avatar), including chairs, vehicles and so forth.}}
+
 
{{ScriptFunction|void|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)}}
+
{{ScriptFunction|void|Detach|();|Detaches the avatar from whatever it may be attached to (only works for the player avatar), including chairs, vehicles and so forth.|5=<pre>Space.Scene.PlayerAvatar.Detach()</pre>}}
 +
 
 +
{{ScriptFunction|void|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)|5=<pre>Space.Scene.PlayerAvatar.AttachTo(targetObject)</pre>}}
 +
 
 
{{ScriptFunction|SGameObject|FindBone|(string bone);|Retrieves the specified bone.|5=
 
{{ScriptFunction|SGameObject|FindBone|(string bone);|Retrieves the specified bone.|5=
 
<b>-- Best used with non humanoid models</b><br>
 
<b>-- Best used with non humanoid models</b><br>
Line 44: Line 43:
 
<b>Right Hand (Little)</b>: RightLittleProximal, RightLittleIntermediate, RightLittleDistal<br>
 
<b>Right Hand (Little)</b>: RightLittleProximal, RightLittleIntermediate, RightLittleDistal<br>
 
]]}}
 
]]}}
 +
 +
 +
==Properties==
 +
{{ScriptFunction|string|Username|{ get; }|Returns the players current username (note: this can be changed by players for a small fee)|5=<pre>playerUsername = Space.Scene.PlayerAvatar.Username</pre>}}
 +
 +
{{ScriptFunction|string|Title|{ get; }|Returns the players current title|5=<pre>playerTitle = Space.Scene.PlayerAvatar.Title</pre>}}
 +
 +
{{ScriptFunction|long|ID|{ get; }|Returns the players user ID, please note if you store these, this is a 'long' value not a 'int'.|5=<pre>playerID = Space.Scene.PlayerAvatar.ID</pre>}}
 +
 +
{{ScriptFunction|SGameObject|GameObject|{ get; }|Returns a reference to the players GameObject|5=<pre>playerObject = Space.Scene.PlayerAvatar.GameObject</pre>}}
  
 
{{Scripting Navbox}}
 
{{Scripting Navbox}}

Revision as of 11:35, 19 December 2020

The SAvatar class refers a single player avatar active within the scene. This only contains active players with a valid network connection, and does not include NPCs.

Members

Detach

void Detach ();

Detaches the avatar from whatever it may be attached to (only works for the player avatar), including chairs, vehicles and so forth.

Space.Scene.PlayerAvatar.Detach()


AttachTo

void 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)

Space.Scene.PlayerAvatar.AttachTo(targetObject)


FindBone

SGameObject FindBone (string bone);

Retrieves the specified bone.

-- Best used with non humanoid models

local bone = Space.Scene.PlayerAvatar.FindBone("Hips/Spine/Chest/LeftShoulder"); -- Gets the bone by path
Space.Log(bone.Name); -- Prints the retrieved bones name, which will match the last name in the path specified.

or

-- Best used with humanoid models
local bone = Space.Scene.PlayerAvatar.FindBone("LeftShoulder"); -- Gets bone by UnityEngine.HumanTrait.BoneName[]
Space.Log(bone.Name); -- Prints the bone name of the corresponding search parameter, which when using a default avatar, it will print "LeftShoulder"

--[[
UnityEngine.HumanTrait.BoneName[]

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

]]



Properties

Username

string Username { get; }

Returns the players current username (note: this can be changed by players for a small fee)

playerUsername = Space.Scene.PlayerAvatar.Username


Title

string Title { get; }

Returns the players current title

playerTitle = Space.Scene.PlayerAvatar.Title


ID

long ID { get; }

Returns the players user ID, please note if you store these, this is a 'long' value not a 'int'.

playerID = Space.Scene.PlayerAvatar.ID


GameObject

SGameObject GameObject { get; }

Returns a reference to the players GameObject

playerObject = Space.Scene.PlayerAvatar.GameObject