ほとんどのゲームではプレイヤーが自分のRobloxアバターを使用できますが、一部のゲームではUGCホームストアテンプレートのようなゲーム内カスタマイズシステムを実装しています。他のゲームでは、ヘルメット、翼、またはジャンルに合ったアクセサリーなど、プレイヤーアバターに対して制限された変更を行います。
ユーザーの外見を変更するユニークなゲームを作成するには、アバター設定または手動で外見を変更を使用して、デフォルトのキャラクターのプロパティをカスタマイズできます。
グローバルアバター設定
スタジオのファイル ⟩ アバター設定により、ゲーム内のプレイヤーキャラクターのプロパティを迅速に設定できます。これらの設定は、ゲームに参加するすべてのプレイヤーキャラクターモデルにグローバルに適用されます。特定のキャラクターを変更するには、非プレイヤーキャラクターモデルなどには手動で外見を変更を参照してください。
このウィンドウでは、服装、アクセサリー、体の部品、衝突の挙動、アニメーションなど、さまざまなプリセットを設定できます。これらの設定を編集すると、適用された設定のプレビューが作業スペースに表示されます。
詳細については、アバター設定を参照してください。
手動で外見を変更
キャラクターモデルには、モデルに特別な特性を与えるHumanoidオブジェクトが含まれています。これにより、歩行、ジャンプ、アイテムの装備、および環境とのインタラクションが可能になります。
HumanoidDescriptionを更新することで、Humanoidをプログラム的に変更できます。これには、ゲーム内のプレイヤーキャラクターモデルや非プレイヤーキャラクターモデルが含まれます。
HumanoidDescriptionを使用して、ゲーム内の以下のキャラクタープロパティを調整できます。
| キャラクタープロパティ | 説明 |
|---|---|
| スケール | 物理的特性の数値 height、width、head、body type、および proportion。これはR6ボディタイプには影響しません。 |
| アクセサリー | キャラクターが装備している accessories のアセットID。 |
| クラシック衣類 | キャラクターに適用できる Shirt、Pants、および ShirtGraphic の画像テクスチャのアセットID。 |
| ボディパーツ | キャラクターの Face、Head、Torso、RightArm、LeftArm、RightLeg、および LeftLegのアセットID。 |
| ボディカラー | キャラクターの各パーツの BodyColors。 |
| アニメーション | キャラクターに使用できる Animations のアセットID。 |
以下の手順を使用して、HumanoidDescriptionでキャラクターをカスタマイズできます。
- ユーザーのキャラクター、特定のアウトフィットID、または特定のユーザーIDから説明を作成します。
- 説明を適用します。単一のキャラクター、すべてのプレイヤーキャラクター、またはすべての出現キャラクターに対しても適用できます。
HumanoidDescriptionを作成
以下のコードを使用して、エクスプローラーの階層内またはScript内で新しいHumanoidDescriptionインスタンスを直接作成できます。
local humanoidDescription = Instance.new("HumanoidDescription")ほとんどの場合、既存のプレイヤーキャラクター、アバターのアウトフィット、またはユーザーIDを参照して、デフォルトの新しいHumanoidDescriptionではなく、既存のHumanoidDescriptionを使用すべきです。
プレイヤーキャラクターから
プレイヤーキャラクターの現在のプロパティに基づいて、新しいHumanoidDescriptionを作成するために、以下のコードサンプルを使用します。
local humanoid = player.Character and player.Character:FindFirstChildWhichIsA("Humanoid")
local humanoidDescription = Instance.new("HumanoidDescription")
if humanoid then
humanoidDescription = humanoid:GetAppliedDescription()
end既存のアウトフィットから
以下のサンプルコードを使用して、Players.GetHumanoidDescriptionFromOutfitIDを使用したアウトフィットIDからHumanoidDescriptionを作成します。
local Players = game:GetService("Players")
local outfitId = 480059254
local humanoidDescriptionFromOutfit = Players:GetHumanoidDescriptionFromOutfitId(outfitId)特定のユーザーから
以下のサンプルコードを使用して、Players:GetHumanoidDescriptionFromUserId()を使用したユーザーIDからHumanoidDescriptionを作成します。
local Players = game:GetService("Players")
local userId = 491243243
local humanoidDescriptionFromUser = Players:GetHumanoidDescriptionFromUserId(userId)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を対象にできます。次のコードを使用して、プレイヤーキャラクターに新しいサングラスと新しい胴体を追加します。
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を適用します。
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を設定します。
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インスタンスがエクスプローラー内で作成され、ワークスペースに親付けされている場合、以下のサンプルコードを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での重ね着アクセサリー
重ね着アクセサリーは、WrapTargetおよびWrapLayerを使用してターゲットModelに伸びたり、巻きついたりします。重ね着アクセサリーは、標準のR15 Robloxキャラクターと非R15モデルの両方で機能します。
独自のケージUVマップを使用しているモデルなど、重ね着アクセサリーのカスタム実装は、マーケットプレイスにアップロードしたり公開したりすることはできません。詳細については、重ね着アクセサリーの仕様を参照してください。
アバターR15リグに重ね着アクセサリーを実装する場合でも、カスタムリグを使用する場合でも、アクセサリーとボディには次のことを確認してください。
- ターゲットモデル(通常はボディ)は、追加のモデルが巻きつくことを意図しているメッシュに WrapTarget コンポーネントがあります。
- レイヤリングモデル(通常は衣類またはアクセサリー)は、ターゲットモデルを巻きつけることを意図したメッシュに WrapLayer コンポーネントがあります。
- ターゲットモデルの外部ケージと、レイヤリングモデルの内外のケージは、同じUVマップを持っています。
- ターゲットケージの対応する頂点は、レイヤーケージの同じ頂点のUVと一致している必要があります。
- ターゲットモデルがR15であり、Humanoidを含む場合、このウェルドは自動的に作成されます。