角色外观

*此内容使用人工智能(Beta)翻译,可能包含错误。若要查看英文页面,请点按 此处

大多数体验都让玩家使用自己的 Roblox 虚拟形象,虽然有些实现了体验内的自定义系统,例如 UGC Homestore 模板。其他体验会对头盔、翅膀或匹配类型的饰品等玩家虚拟形象进行限定修改

要创建一个改变用户外观的独特体验,您可以使用以关注中/正在关注方法来自定义默认角色属性:

  • 配置虚拟形象 游戏设置 以设置所有用户的基本全球虚拟形象默认外观。
  • 在任何时候使用 人形描述 来应用广泛的特定角色自定义到你体验中的一个或多个用户。

游戏设置

游戏设置菜单中的 虚拟形象 部分可让您快速设置体验中的多个全球角色属性。当编辑虚拟形象游戏设置时,你的虚拟形象在工作区中显示为视觉预览。

您可以使用虚拟形象游戏设置调整以下角色属性在您的体验中:

设置描述
预设应用一个共同的集合 BodyTypeScaleProportionScale 组合。您可以在选择预设之后再次调整这些属性,使用 HumanoidDescription
虚拟形象类型将默认虚拟形象类型设置为 either R15R6
动画用户可以访问的 Animations 一组。
协同作用为体验中的角色设置碰撞边界
身体部件角色的 Face , Head , Torso , RightArm , LeftArm , RightLegLeftLeg 部分的资产ID。
服装你可以应用到角色的经典 Shirt , PantsShirtGraphic 图像纹理的资产ID。

虚拟形象类型

虚拟形象类型 设置将您的体验设置为仅加载 R15R6 角色模型。

  • R15 是默认的现代虚拟形象,拥有 15 个肢体。这个虚拟形象允许更灵活的自定义、配件选项和动画。

  • R6 是一个经典简单的虚拟形象,拥有6个肢体。这种虚拟形象类型提供了复古感,但在动画和额外的自定义方面受到限制。身体比例属性的更改不会影响 R6 角色。

R15角色模型。
>

R6角色模型。
>

碰撞边界

碰撞 设置设置体验中角色的碰撞边界。这不会影响你体验中角色的物理外观。

将此选项设置为 外部盒子 会动态地将角色的碰撞箱大小调整为基于其个人模型的。这是大多数体验的默认和推荐设置。

将此选项设置为 内部盒子 为您体验中的所有角色提供固定的碰撞边界。

人形描述

可玩角色模型包含一个 Humanoid 对象,可以允许模型具有特殊功能,例如行走、跳跃、装备物品和与环境互动。要自定义 Humanoid 角色的外观,您可以应用新的 HumanoidDescription 来更改角色属性。

您可以使用 HumanoidDescription 在体验中调整以下角色属性:

角色属性描述
缩放物理特性数值 height , width , head , body typeproportion . 这不会影响 R6 身体类型。
配件由角色装备的资产ID accessories
经典服装你可以应用到角色的资产ID Shirt , Pants , 和 ShirtGraphic 图像纹理。
身体部分角色的 Face , Head , Torso , RightArm , LeftArm , RightLegLeftLeg 部分的资产ID。
身体颜色角色的个别部分的 BodyColors
动画你可以在角色上使用的资产ID Animations

您可以使用以下步骤自定义角色 HumanoidDescription

  1. 修改描述 来自定义你想要应用于 Humanoid 角色的属性。
  2. 应用描述 单个角色、所有玩家角色或甚至所有生成角色。

创建人形描述

您可以直接在 Explorer 层次中创建新的 HumanoidDescription 实例或在 Script 中使用以下验证码创建:


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

从现有服装

使用以下示例代码创建一个使用 HumanoidDescription 从服装 ID 中的 Players.GetHumanoidDescriptionFromOutfitID


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

来自特定用户

使用以下示例代码创建一个 HumanoidDescription 从用户 ID 使用 Players:GetHumanoidDescriptionFromUserId() 创建一个:


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"
-- 将修改的“descriptionClone”应用于人形
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)
-- 使用 “工作区.StudioHumanoidDescription” 生成角色
player:LoadCharacterWithHumanoidDescription(workspace.StudioHumanoidDescription)
end
-- 将“玩家添加”事件连接到“onPlayerAdded()”函数
Players.PlayerAdded:Connect(onPlayerAdded)