角色外觀

*此內容是使用 AI(Beta 測試版)翻譯,可能含有錯誤。若要以英文檢視此頁面,請按一下這裡

大多數體驗讓玩家使用自己的 Roblox 人物,雖然有些會實現體驗內的自訂系統,例如 UGC Homestore 樣板。其他體驗會對玩家頭盔、翅膀或配件等進行限定修改,以符合類類別。

若要創建一種獨特的體驗,可以使用以追蹤中方式自訂預設角色屬性,以改變使用者的外觀:

  • 配置 Avatar 遊戲設定來設置所有用戶的基本全球虛擬人偶外觀默認值。
  • 在任何時候使用 人形描述 來應用廣泛的特定角色自訂到您體驗中的一名或多名用戶。

游戲設定

在 遊戲設定 選單中的 頭像 部分可讓您快速設置體驗中的多個全球角色屬性。當編輯虛擬人偶遊戲設定時,你的虛擬人偶會在工作區中顯示為視覺預覽。

您可以使用虛擬人偶遊戲設定來調整以下角色屬性在體驗中:

設置說明
預設值應用一組共用的 BodyTypeScaleProportionScale 組合。您可以在選擇預設後再調整這些屬性,使用 HumanoidDescription
人物類型將預設 人物類型 設置為 R15R6
動畫使用者可以存取的 Animations 一組設定。
碰撞為體驗中的字元設置 碰撞邊界
身體部位角色的 Face , Head , Torso , RightArm , LeftArm , RightLegLeftLeg 部分的資產ID。
服裝你可以應用於角色的經典 ShirtPantsShirtGraphic 圖像紋理的資產ID。

人物類型

虛擬人偶類型 設定將您的體驗設置為只載入 R15R6 角色模型。

  • R15 是預設的現代化身像,擁有 15 個肢體。這個身像允許更靈活的自訂、配件選項和動畫。

  • R6 是一個經典簡單的虛擬人偶,有6個肢體。這種虛擬人偶類型提供了復古感,但在動畫和額外的自訂方面受限。身體比例規屬性的變更不會影響 R6 角色。

R15 角色模型。
R6 角色模型。

碰撞邊界

碰撞 設定設置體驗中角色的碰撞邊界。這不會影響您體驗中角色的物理外觀。

將此選項設為 外部箱子 會動態地調整角色的碰撞箱大小,根據其個別模型。這是大多數體驗的預設和建議設定。

將此選項設為 內部盒子 為您體驗中的所有角色提供固定的碰撞邊界。

人形描述

可玩角色模型包含一個 Humanoid 對象,可以允許模型具有特殊功能,例如行走、跳躍、裝備物品和與環境互動。若要自訂 Humanoid 角色的外觀,您可以使用新的 HumanoidDescription 來變更角色屬性。

您可以使用 HumanoidDescription 在體驗中調整以下角色屬性:

角色屬性說明
比例物理特性數值 height , width , head , body typeproportion 。這不會影響 R6 身體類型。
配件角色裝備的資產IDaccessories
經典服裝你可以應用到角色的 Shirt , PantsShirtGraphic 圖像紋理的資產ID。
身體部位角色的 Face , Head , Torso , RightArm , LeftArm , RightLegLeftLeg 部分的資產ID。
身體顏色角色的個別部分的 BodyColors
動畫你可以在角色上使用的資產ID Animations

您可以使用以下步驟自訂角色 HumanoidDescription

  1. 修改說明 以自訂您想要應用於 Humanoid 角色的屬性。
  2. 應用說明 單個字符、所有玩家角色或甚至所有生成角色。

創建人形描述

您可以直接在 Explorer 層級中或在 Script 中創建新的 HumanoidDescription 實例,使用以下代碼:


local humanoidDescription = Instance.new("HumanoidDescription")

在大多數情況下,您應該使用現有的 而不是預設新的 ,引用現有玩家角色 》、 虛擬人偶服裝 或 使用者ID 。

從玩家角色

使用以下代碼示例來創建一個新的 HumanoidDescription 基於玩家角色的當前屬性:


local humanoid = player.Character and player.Character:FindFirstChildWhichIsA("Humanoid")
local humanoidDescription = Instance.new("HumanoidDescription")
if humanoid then
humanoidDescription = humanoid:GetAppliedDescription()
end

從現有服裝

使用以下示例代碼,創建從服裝ID中使用 HumanoidDescription 生成Players.GetHumanoidDescriptionFromOutfitID


local Players = game:GetService("Players")
local outfitId = 480059254
local humanoidDescriptionFromOutfit = Players:GetHumanoidDescriptionFromOutfitId(outfitId)

來自特定使用者

使用以下示例代碼創建一個 HumanoidDescription 從使用 Players:GetHumanoidDescriptionFromUserId() 的用戶ID中:


local Players = game:GetService("Players")
local userId = 491243243
local humanoidDescriptionFromUser = Players:GetHumanoidDescriptionFromUserId(userId)

修改人形描述

若要自訂 HumanoidDescription 屬性,請直接在 HumanoidDescription 上設置它們,或在使用 HumanoidDescription 應用到角色之前使用指定的方法。

以下代碼示例提供了不同類型的 HumanoidDescription 屬性設置的例子:


local humanoidDescription = Instance.new("HumanoidDescription")
humanoidDescription.HatAccessory = "2551510151,2535600138"
humanoidDescription.BodyTypeScale = 0.1
humanoidDescription.ClimbAnimation = 619521311
humanoidDescription.Face = 86487700
humanoidDescription.GraphicTShirt = 1711661
humanoidDescription.HeadColor = Color3.new(0, 1, 0)

設定多個配件

對於分層或大量配件變更,您可以使用 HumanoidDescription:SetAccessories() 來進行配件相關更新。以下代碼示例在此順序中添加分層毛衣和外套:HumanoidDescription :


local humanoidDescription = Instance.new("HumanoidDescription")
local accessoryTable = {
{
Order = 1,
AssetId = 6984769289,
AccessoryType = Enum.AccessoryType.Sweater
},
{
Order = 2,
AssetId = 6984767443,
AccessoryType = Enum.AccessoryType.Jacket
}
}
humanoidDescription:SetAccessories(accessoryTable, false)

應用人形描述

應用 HumanoidDescription 到您的體驗中的特定 Humanoid 角色使用 Humanoid:ApplyDescription()Humanoid.LoadCharacterWithHumanoidDescription

在單一角色上

ApplyDescription() 可以瞄準任何 Humanoid 。使用以下代碼將新的太陽眼鏡和新的軀體添加到玩家角色:


local humanoid = player.Character and player.Character:FindFirstChildWhichIsA("Humanoid")
if humanoid then
local descriptionClone = humanoid:GetAppliedDescription()
descriptionClone.Torso = 86500008
-- 分開使用的多個面部配件資產可以在逗號分隔的字串中允許
descriptionClone.FaceAccessory = descriptionClone.FaceAccessory .. ",2535420239"
-- 將修改的「說明複製」應用於人形
humanoid:ApplyDescription(descriptionClone)
end

在所有玩家角色上

使用以下示例代碼,將 HumanoidDescription 應用於遊戲中所有現有玩家:


local Players = game:GetService("Players")
for _, player in Players:GetPlayers() do
local humanoid = player.Character and player.Character:FindFirstChildWhichIsA("Humanoid")
if humanoid then
-- 創建一個人形描述
local humanoidDescription = Instance.new("HumanoidDescription")
humanoidDescription.HatAccessory = "2551510151,2535600138"
humanoidDescription.BodyTypeScale = 0.1
humanoidDescription.ClimbAnimation = 619521311
humanoidDescription.Face = 86487700
humanoidDescription.GraphicTShirt = 1711661
humanoidDescription.HeadColor = Color3.new(0, 1, 0)
humanoid:ApplyDescription(humanoidDescription)
end
end

在所有生成角色上

使用以下示例代碼設置所有生成玩家角色的特定 HumanoidDescription


local Players = game:GetService("Players")
-- 停止自動生成,以便在「PlayerAdded」呼叫中完成
Players.CharacterAutoLoads = false
local function onPlayerAdded(player)
-- 創建一個人形描述
local humanoidDescription = Instance.new("HumanoidDescription")
humanoidDescription.HatAccessory = "2551510151,2535600138"
humanoidDescription.BodyTypeScale = 0.1
humanoidDescription.ClimbAnimation = 619521311
humanoidDescription.Face = 86487700
humanoidDescription.GraphicTShirt = 1711661
humanoidDescription.HeadColor = Color3.new(0, 1, 0)
-- 使用 HumanoidDescription 生成角色
player:LoadCharacterWithHumanoidDescription(humanoidDescription)
end
-- 將「玩家新增」事件連接到「onPlayerAdded()」功能
Players.PlayerAdded:Connect(onPlayerAdded)

如果 HumanoidDescription 實例在 Explorer 中創建並指向工作區,請在 Script 中使用以下示例代碼存取工作區實個體、實例:


local Players = game:GetService("Players")
-- 停止自動生成,以便在「PlayerAdded」呼叫中完成
Players.CharacterAutoLoads = false
local function onPlayerAdded(player)
-- 使用「workspace.StudioHumanoidDescription」生成角色
player:LoadCharacterWithHumanoidDescription(workspace.StudioHumanoidDescription)
end
-- 將「玩家新增」事件連接到「onPlayerAdded()」功能
Players.PlayerAdded:Connect(onPlayerAdded)