wiki.sine.space | sinespace

Difference between revisions of "Scripting/SAvatar"

From wiki.sine.space
Jump to: navigation, search
(Added, defined and give simple examples to .BlockMovement .Guest .Skeleton .IsAttached .IsGrounded .JumpHeight .Loaded .MovementSpeed .OutfitID)
m
Line 64: Line 64:
 
{{ScriptFunction|bool|IsGrounded|{ get; }|Returns True if avatar is Grounded|5=<pre>Space.Log(Space.Scene.PlayerAvatar.isGrounded)</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|float|JumpHeight|{ get;set; }|How high the avatar's jump is|5=<pre>Space.Scene.PlayerAvatar = 20</pre>}}
  
 
{{ScriptFunction|bool|Loaded|{ get; }|Returns true if avatar is Loaded|5=<pre>Space.Log(Space.Scene.PlayerAvatar.Loaded)</pre>}}
 
{{ScriptFunction|bool|Loaded|{ get; }|Returns true if avatar is Loaded|5=<pre>Space.Log(Space.Scene.PlayerAvatar.Loaded)</pre>}}

Revision as of 13:34, 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; }

How high the avatar's jump is

Space.Scene.PlayerAvatar = 20


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