角色外观

*此内容使用人工智能(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

通过 Humanoid:ApplyDescription()Humanoid.LoadCharacterWithHumanoidDescriptionHumanoidDescription 应用于您游戏中的特定 Humanoid 角色。

对单个角色

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)

如果在 Explorer 中创建了 HumanoidDescription 实例并将其父级设置为工作区,使用以下示例代码在 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 Roblox 角色 和非 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 是我们在美国及其他国家或地区的注册与未注册商标。