wiki.sine.space | sinespace

Difference between revisions of "Scripting/SAvatar"

From wiki.sine.space
Jump to: navigation, search
m
(Added, defined and give simple examples to .BlockMovement .Guest .Skeleton .IsAttached .IsGrounded .JumpHeight .Loaded .MovementSpeed .OutfitID)
Line 1: Line 1:
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.
+
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. ((PlayerAvatar being used below is just an example, as it returns an SAvatar.))
  
 
=Members=
 
=Members=
Line 46: Line 46:
  
 
=Properties=
 
=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|Username|{ get; }|Returns the avatar's 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|string|Title|{ get; }|Returns the avatar's 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|long|ID|{ get; }|Returns the avatar's 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>}}
+
{{ScriptFunction|SGameObject|GameObject|{ get; }|Returns a reference to avatar's GameObject|5=<pre>playerObject = Space.Scene.PlayerAvatar.GameObject</pre>}}
 +
 
 +
{{ScriptFunction|bool|BlockMovement|{ get;set; }|If set to True, avatar's movement will be blocked|5=<pre>Space.Scene.PlayerAvatar.BlockMovement = true</pre>}}
 +
 
 +
{{ScriptFunction|bool|Guest|{ get; }|Returns True if avatar is guest|5=<pre>Space.Log(Space.Scene.PlayerAvatar.BlockMovement)</pre>}}
 +
 
 +
{{ScriptFunction|SGameObject|Skeleton|{ get; }|Returns a reference to avatar's skeleton GameObject|5=<pre>avSkeleton = Space.Scene.PlayerAvatar.Skeleton</pre>}}
 +
 
 +
{{ScriptFunction|bool|IsAttached|{ get; }|Returns True if avatar is Attached|5=<pre>Space.Log(Space.Scene.PlayerAvatar.isAttached)</pre>}}
 +
 
 +
{{ScriptFunction|bool|IsGrounded|{ get; }|Returns True if avatar is Grounded|5=<pre>Space.Log(Space.Scene.PlayerAvatar.isGrounded)</pre>}}
 +
 
 +
{{ScriptFunction|float|JumpHeight|{ get;set; }|Space.Scene.PlayerAvatar = 20|5=<pre></pre>}}
 +
 
 +
{{ScriptFunction|bool|Loaded|{ get; }|Returns true if avatar is Loaded|5=<pre>Space.Log(Space.Scene.PlayerAvatar.Loaded)</pre>}}
 +
 
 +
{{ScriptFunction|float|MovementSpeed|{ get;set; }|How fast the avatar's movement is|5=<pre>Space.Scene.PlayerAvatar = 20</pre>}}
 +
 
 +
{{ScriptFunction|long|OutfitID|{ get; }|Returns the current outfit ID of the avatar|5=<pre>avOutfit = Space.Scene.PlayerAvatar.OutfitID</pre>}}
  
 
{{Scripting Navbox}}
 
{{Scripting Navbox}}

Revision as of 13:33, 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. ((PlayerAvatar being used below is just an example, as it returns an SAvatar.))

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 avatar's current username (note: this can be changed by players for a small fee)

playerUsername = Space.Scene.PlayerAvatar.Username


Title

string Title { get; }

Returns the avatar's current title

playerTitle = Space.Scene.PlayerAvatar.Title


ID

long ID { get; }

Returns the avatar's 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 avatar's GameObject

playerObject = Space.Scene.PlayerAvatar.GameObject


BlockMovement

bool BlockMovement { get;set; }

If set to True, avatar's movement will be blocked

Space.Scene.PlayerAvatar.BlockMovement = true


Guest

bool Guest { get; }

Returns True if avatar is guest

Space.Log(Space.Scene.PlayerAvatar.BlockMovement)


Skeleton

SGameObject Skeleton { get; }

Returns a reference to avatar's skeleton GameObject

avSkeleton = Space.Scene.PlayerAvatar.Skeleton


IsAttached

bool IsAttached { get; }

Returns True if avatar is Attached

Space.Log(Space.Scene.PlayerAvatar.isAttached)


IsGrounded

bool IsGrounded { get; }

Returns True if avatar is Grounded

Space.Log(Space.Scene.PlayerAvatar.isGrounded)


JumpHeight

float JumpHeight { get;set; }

No documentation


Loaded

bool Loaded { get; }

Returns true if avatar is Loaded

Space.Log(Space.Scene.PlayerAvatar.Loaded)


MovementSpeed

float MovementSpeed { get;set; }

How fast the avatar's movement is

Space.Scene.PlayerAvatar = 20


OutfitID

long OutfitID { get; }

Returns the current outfit ID of the avatar

avOutfit = Space.Scene.PlayerAvatar.OutfitID