角色外觀

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

大多數遊戲允許玩家使用自己的 Roblox 角色,儘管有些遊戲實現了像 UGC Homestore 模板的遊戲內自訂系統。其他遊戲對玩家角色進行有限的 修改,例如頭盔、翅膀或與類型相符的配件。

要創建一個獨特的遊戲來改變用戶的外觀,您可以通過 角色設定手動修改外觀 來自訂預設角色屬性。

全局角色設定

Studio 的 檔案角色設定 允許您快速設置遊戲中多個全局玩家角色屬性。這些設定適用於所有加入您遊戲的玩家角色模型。要修改特定角色,例如非玩家角色模型,請參見 手動修改外觀

在此窗口中,您可以設置各種預設的服裝、配件、身體部位、碰撞行為、動畫等。編輯這些設定時,應用的設定預覽會顯示在工作區中。

欲了解更多信息,請參見 角色設定

手動修改外觀

角色模型包含一個 Humanoid 對象,該對象賦予模型特殊特徵,例如行走、跳躍、裝備物品和與環境互動。

您可以通過更新 HumanoidDescription 來以編程方式修改 Humanoid。這包括您遊戲中的玩家角色模型或非玩家角色模型。

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

角色屬性描述
比例物理特徵的數值 heightwidthheadbody typeproportion。這不影響 R6 身體類型。
配件角色裝備的 accessories 的資產 ID。
經典服裝您可以應用於角色的 ShirtPantsShirtGraphic 圖像紋理的資產 ID。
身體部位角色的 FaceHeadTorsoRightArmLeftArmRightLegLeftLeg 部分的資產 ID。
身體顏色角色各個部位的 BodyColors
動畫您可以在角色上使用的 Animations 的資產 ID。

使用 HumanoidDescription 自訂角色的步驟如下:

  1. 從用戶角色創建描述、特定的服裝 ID 或特定的用戶 ID。
  2. 修改描述 以自訂您想要應用於 Humanoid 角色的屬性。
  3. 應用描述 到單個角色、所有玩家角色,甚至所有生成的角色。

創建 HumanoidDescription

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

創建新的 HumanoidDescription 實例
local humanoidDescription = Instance.new("HumanoidDescription")

在大多數情況下,您應該使用現有的 HumanoidDescription,而不是默認的新 HumanoidDescription,通過引用現有的玩家角色、角色服裝或用戶 ID。


從玩家角色

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

從玩家角色生成 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

從服裝 ID 生成 HumanoidDescription
local Players = game:GetService("Players")
local outfitId = 480059254
local humanoidDescriptionFromOutfit = Players:GetHumanoidDescriptionFromOutfitId(outfitId)

從特定用戶

使用以下示例代碼從用戶 ID 創建 HumanoidDescription,使用 Players:GetHumanoidDescriptionFromUserId()

從用戶 ID 生成 HumanoidDescription
local Players = game:GetService("Players")
local userId = 491243243
local humanoidDescriptionFromUser = Players:GetHumanoidDescriptionFromUserId(userId)

修改 HumanoidDescription

要自訂 HumanoidDescription 屬性,直接在 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

HumanoidDescription 應用於您遊戲中的特定 Humanoid 角色,使用 Humanoid:ApplyDescription()Humanoid.LoadCharacterWithHumanoidDescription

在單個角色上

ApplyDescription() 可以針對任何 Humanoid。使用以下代碼為玩家角色添加一副新的太陽眼鏡和一個新的軀幹:

更新特定玩家角色的 HumanoidDescription
local humanoid = player.Character and player.Character:FindFirstChildWhichIsA("Humanoid")
if humanoid then
local descriptionClone = humanoid:GetAppliedDescription()
descriptionClone.Torso = 86500008
-- 允許在逗號分隔的字符串中使用多個面部配件資產
descriptionClone.FaceAccessory = descriptionClone.FaceAccessory .. ",2535420239"
-- 將修改過的 "descriptionClone" 應用於 humanoid
humanoid:ApplyDescription(descriptionClone)
end

在所有玩家角色上

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

更新所有當前玩家角色的 HumanoidDescription
local Players = game:GetService("Players")
for _, player in Players:GetPlayers() do
local humanoid = player.Character and player.Character:FindFirstChildWhichIsA("Humanoid")
if humanoid then
-- 創建一個 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)
humanoid:ApplyDescription(humanoidDescription)
end
end

在所有生成的角色上

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

更新所有生成角色的 HumanoidDescription
local Players = game:GetService("Players")
-- 停止自動生成,以便在 "PlayerAdded" 回調中進行
Players.CharacterAutoLoads = false
local function onPlayerAdded(player)
-- 創建一個 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 生成角色
player:LoadCharacterWithHumanoidDescription(humanoidDescription)
end
-- 將 "PlayerAdded" 事件連接到 "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
-- 將 "PlayerAdded" 事件連接到 "onPlayerAdded()" 函數
Players.PlayerAdded:Connect(onPlayerAdded)

非 R15 的分層配件

籠狀配件,如分層配件,使用 WrapTargetWrapLayer 在目標 Model 上拉伸和包裹。分層配件可以與標準 玩家角色 和非 R15 模型一起使用。

自定義實現的分層配件,例如使用獨特籠狀 UV 地圖的模型,無法上傳並發布到市場。欲了解更多信息,請參見 分層配件規範

無論您是在 R15 角色上實現分層配件,還是使用自定義角色,請確保您的配件和身體包含以下內容:

  • 目標模型,通常是身體,在要包裹的網格上具有 WrapTarget 組件。
  • 分層模型,通常是服裝或配件,在要包裹目標模型的網格上具有 WrapLayer 組件。
  • 目標模型的 外部籠分層模型的內部和外部籠 具有匹配的 UV 地圖。
    • 目標籠上對應的頂點應具有與分層籠上那些頂點相同的 UV。
  • 如果您的目標模型不是 R15,或不包含 Humanoid,則必須將 Weld 對象添加到分層的 MeshPart
    • Weld 必須將 Part0Part1 設置為將分層 MeshPart 連接到模型的部件層級。例如,Part0 指的是配件,Part1 指的是父部件。
  • 如果您的目標模型同時是 R15 並且包含 Humanoid,則此焊接會自動創建。
©2026 Roblox Corporation、Roblox、Roblox 標誌及 Powering Imagination 是我們在美國及其他國家地區的部分註冊與未註冊商標。