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.))
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()
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)
Retrieves the specified bone.
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
Returns the avatar's current username (note: this can be changed by players for a small fee)
playerUsername = Space.Scene.PlayerAvatar.Username
Returns the avatar's current title
playerTitle = Space.Scene.PlayerAvatar.Title
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
Returns a reference to avatar's GameObject
playerObject = Space.Scene.PlayerAvatar.GameObject
If set to True, avatar's movement will be blocked
Space.Scene.PlayerAvatar.BlockMovement = true
Returns True if avatar is guest
Space.Log(Space.Scene.PlayerAvatar.BlockMovement)
Returns a reference to avatar's skeleton GameObject
avSkeleton = Space.Scene.PlayerAvatar.Skeleton
Returns True if avatar is Attached
Space.Log(Space.Scene.PlayerAvatar.isAttached)
Returns True if avatar is Grounded
Space.Log(Space.Scene.PlayerAvatar.isGrounded)
How high the avatar's jump is
Space.Scene.PlayerAvatar = 20
Returns true if avatar is Loaded
Space.Log(Space.Scene.PlayerAvatar.Loaded)
How fast the avatar's movement is
Space.Scene.PlayerAvatar = 20
Returns the current outfit ID of the avatar
avOutfit = Space.Scene.PlayerAvatar.OutfitID
Reset current outfit.
local avatar=Space.Scene.PlayerAvatar avatar.ResetOutfit()
Allow a guest to register.
local avatar=Space.Scene.PlayerAvatar avatar.Register("MyName","MyPassword","MyEmail",false,function () Space.Log("Success!") end,function () Space.Log("OnError!!") end)
Only works on a white-label deployment due to abuse concerns.
local avatar=Space.Scene.PlayerAvatar avatar.LoadOutfit(10001)
Reset current outfit to template one.
local avatar=Space.Scene.PlayerAvatar avatar.ResetOutfitToTemplate(10001)
Teleport the avatar to the landmark.
local avatar=Space.Scene.PlayerAvatar avatar.Teleport("MyLandMark")
Teleport the avatar to certain position.
local avatar=Space.Scene.PlayerAvatar avatar.Teleport(Vector.Zero)
Teleport the avatar to certain position and rotation.
local avatar=Space.Scene.PlayerAvatar avatar.Teleport(Vector.Zero,Quaternion.Identity)
Teleport the avatar to a certain region with certain position and rotation.
local avatar=Space.Scene.PlayerAvatar avatar.Teleport(2342341,Vector.Zero,Quaternion.Identity)
Teleport the avatar to a certain.
local avatar=Space.Scene.PlayerAvatar avatar.Teleport(2342341)
Set the IK goal to avatar.
local avatar=Space.Scene.PlayerAvatar local pos=avatar.FindBone("Chest").WorldPosition avatar.SetIKGoal("Chest",false,0,pos,true,20,Quaternion.Euler(0,60,0))
Clear the IK Goal.
local avatar=Space.Scene.PlayerAvatar local 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.''
Make the avatar plays custom animation.
local avatar=Space.Scene.PlayerAvatar avatar.PlayCustomAnimation(Space.Resources[1]) '' --the avatar will play the custom animation if the animation clip was set correctly.''
Make the avatar stops playing custom animation.
local avatar=Space.Scene.PlayerAvatar avatar.PlayCustomAnimation(Space.Resources[1]) avatar.StopCustomAnimation()
Lock the avatar.
local avatar=Space.Scene.PlayerAvatar local obj=avatar.LockObject.Name if obj~=nil then Space.Log(obj.Name) end
This event will be called when the avatar gets loaded.
local avatar=Space.Scene.PlayerAvatar avatar.OnAvatarReload(function () Space.Log(avatar.OutfitID) end)
Synchronise avatar's state to network.
local avatar=Space.Scene.PlayerAvatar avatar.SynchroniseState()
Returns true if the avatar could run.
local avatar=Space.Scene.PlayerAvatar Space.Log(avatar.BlockRun) avatar.BlockRun=true '' --Now the avatar cannot run anymore.''
Return true if the avatar could fly.
local avatar=Space.Scene.PlayerAvatar Space.Log(avatar.BlockFly) avatar.BlockFly=true '' --Now the avatar cannot fly anymore.''
Return true if the avatar could crouch.
local avatar=Space.Scene.PlayerAvatar Space.Log(avatar.BlockCrouch) avatar.BlockCrouch=true '' --Now the avatar cannot crouch anymore.''
Return true if the avatar could jump.
local avatar=Space.Scene.PlayerAvatar Space.Log(avatar.BlockJump) avatar.BlockJump=true '' --Now the avatar cannot jump anymore.''
This event will be called when the avatar skeleton gets loaded.
local avatar=Space.Scene.PlayerAvatar Space.Log(avatar.BlockJump) avatar.OnAvatarSkeletonReload(function () Space.Log(avatar.OutfitID) end)
|