AvatarPart

继承自

描述

Avatar部件节点

属性

部件位置
string
部件资源id
string
部件贴图资源id
string
部件贴图资源id
bool
是否显示
int
模型id

代码示例


local player = script.Parent.Parent
local playerBody = player.Character

local function changeAvatar()
        local function printSystemAvatarID(avatarName)
                local actorAvatarNode = playerBody.AvatarPartGroup[avatarName]
                print(actorAvatarNode.ModelId)
        end

        local function changeAvatar(avatarName, asset1, asset2, asset3)
                if not asset1 then
                        asset1 = ""
                end
                if not asset2 then
                        asset2 = ""
                end
                if not asset3 then
                        asset3 = ""
                end
                local actorAvatarNode = playerBody.AvatarPartGroup[avatarName]
                actorAvatarNode.ModelResId = asset1
                actorAvatarNode.DiffuseTexResId = asset2
                actorAvatarNode.EmissiveTexResId= asset3
                actorAvatarNode.Show = true
        end

        local function attachCustomAvatar()
                changeAvatar("BODY", "SandboxId&restype=21://entity/player/player12/2.omod")
                changeAvatar("HEAD", "SandboxId&restype=21://entity/player/player12/2.omod")
                changeAvatar("JACKET", "SandboxId&restype=21://entity/player/player12/2.omod")
        end
        
        local function detachCustomAvatar()
                changeAvatar("BODY", "")
                changeAvatar("HEAD", "")
                changeAvatar("JACKET", "")
        end
        printSystemAvatarID("BODY")
        printSystemAvatarID("HEAD")
        printSystemAvatarID("JACKET")
        Wait(3)
        print("attach custom Avatar")
        attachCustomAvatar()
        Wait(3)
        print("detach custom Avatar")
        detachCustomAvatar()
        Wait(3)
end

local function changeSkin()
        local function takeInSkin()
                playerBody.SkinId = 10
        end
        local function takeOffSkin()
                playerBody.SkinId = 0
                playerBody.ModelId = "sandboxSysId://entity/player/player12/body.prefab"
        end
        print(playerBody.SkinId)
        print(playerBody.ModelId)
        Wait(3)
        print("take in skin")
        takeInSkin()
        Wait(3)
        print("take off skin")
        takeOffSkin()
        Wait(3)
end

-- Wait Avatar
Wait(3)
changeAvatar()
changeSkin()
Last Updated: