ほとんどの体験ではプレイヤーは自分のRobloxアバターを使用できますが、一部の体験ではUGCホムストアテンプレートのような体験内カスタマイズシステムを実装しています。他の体験では、ヘルメット、翼、またはジャンルに合わせたアクセサリーのようなプレイヤーアバターへの限られた変更が行われます。
ユーザーの外見を変更するユニークな体験を作成するには、アバター設定を通じてデフォルトのキャラクターのプロパティをカスタマイズするか、外観を手動で変更することができます。
グローバルアバター設定
スタジオのファイル ⟩ アバター設定では、体験内のプレイヤーキャラクターのプロパティを迅速に設定できます。これらの設定は、体験に参加するすべてのプレイヤーキャラクターモデルにグローバルに適用されます。特定のキャラクター、非プレイヤーキャラクターモデルを変更するには、外観を手動で変更するを参照してください。
このウィンドウでは、服装、アクセサリー、体のパーツ、衝突の動作、アニメーションなどのさまざまなプリセットを設定できます。これらの設定を編集すると、適用された設定のプレビューがワークスペースに表示されます。
詳細については、アバター設定を参照してください。
外観を手動で変更する
キャラクターモデルには、歩行、ジャンプ、アイテムの装備、環境との相互作用などの特別な特性を与えるHumanoidオブジェクトが含まれています。
Humanoidを介して、HumanoidDescriptionを更新することでプログラム的に変更できます。これには、プレイヤーキャラクターモデルや体験内の非プレイヤーキャラクターモデルが含まれます。
次のキャラクターのプロパティを、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を使用してキャラクターをカスタマイズします:
- キャラクターから説明を作成する、ユーザーのキャラクター、特定のOutfit ID、または特定のユーザーIDから作成します。
- 説明を適用するして、単一のキャラクター、すべてのプレイヤーキャラクター、またはすべての生成キャラクターに適用します。
HumanoidDescriptionの作成
次のコードを使用して、Explorer階層内またはScript内で新しいHumanoidDescriptionインスタンスを直接作成できます:
新しいHumanoidDescriptionインスタンスを作成するlocal humanoidDescription = Instance.new("HumanoidDescription")
ほとんどのケースでは、デフォルトの新しいHumanoidDescriptionの代わりに、既存のプレイヤーキャラクター、アバターの衣装、またはユーザーIDを参照して既存のHumanoidDescriptionを使用するべきです。
プレイヤーキャラクターから
次のコードサンプルを使用して、プレイヤーキャラクターの現在のプロパティに基づいて新しいHumanoidDescriptionを作成します:
プレイヤーキャラクターからHumanoidDescriptionを生成するlocal humanoid = player.Character and player.Character:FindFirstChildWhichIsA("Humanoid")local humanoidDescription = Instance.new("HumanoidDescription")if humanoid thenhumanoidDescription = humanoid:GetAppliedDescription()end
既存の衣装から
次のサンプルコードを使用して、Players.GetHumanoidDescriptionFromOutfitIDを使用して衣装IDからHumanoidDescriptionを作成します:
Outfit IDからHumanoidDescriptionを生成するlocal Players = game:GetService("Players")local outfitId = 480059254local humanoidDescriptionFromOutfit = Players:GetHumanoidDescriptionFromOutfitId(outfitId)
特定のユーザーから
次のサンプルコードを使用して、Players:GetHumanoidDescriptionFromUserId()を使用してユーザーIDからHumanoidDescriptionを作成します:
ユーザーIDからHumanoidDescriptionを生成するlocal Players = game:GetService("Players")local userId = 491243243local humanoidDescriptionFromUser = Players:GetHumanoidDescriptionFromUserId(userId)
HumanoidDescriptionを変更する
HumanoidDescriptionのプロパティをカスタマイズするには、それらを直接HumanoidDescriptionに設定するか、HumanoidDescriptionをキャラクターに適用する前に指定されたメソッドを使用します。
次のコードサンプルは、異なるタイプのHumanoidDescriptionプロパティを設定する例を提供します:
さまざまなHumanoidDescriptionプロパティを更新するlocal humanoidDescription = Instance.new("HumanoidDescription")humanoidDescription.HatAccessory = "2551510151,2535600138"humanoidDescription.BodyTypeScale = 0.1humanoidDescription.ClimbAnimation = 619521311humanoidDescription.Face = 86487700humanoidDescription.GraphicTShirt = 1711661humanoidDescription.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キャラクターにHumanoidDescriptionをHumanoid:ApplyDescription()またはHumanoid.LoadCharacterWithHumanoidDescription経由で適用します。
単一のキャラクターに対して
ApplyDescription()は任意のHumanoidにターゲットを絞ることができます。次のコードを使用して、プレイヤーキャラクターに新しいサングラスと新しい胴体を追加します:
特定のプレイヤーキャラクターのHumanoidDescriptionを更新するlocal humanoid = player.Character and player.Character:FindFirstChildWhichIsA("Humanoid")if humanoid thenlocal 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() dolocal humanoid = player.Character and player.Character:FindFirstChildWhichIsA("Humanoid")if humanoid then-- HumanoidDescriptionを作成local humanoidDescription = Instance.new("HumanoidDescription")humanoidDescription.HatAccessory = "2551510151,2535600138"humanoidDescription.BodyTypeScale = 0.1humanoidDescription.ClimbAnimation = 619521311humanoidDescription.Face = 86487700humanoidDescription.GraphicTShirt = 1711661humanoidDescription.HeadColor = Color3.new(0, 1, 0)humanoid:ApplyDescription(humanoidDescription)endend
すべての生成キャラクターに対して
次のサンプルコードを使用して、すべての生成プレイヤーキャラクターに特定の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におけるレイヤー服
レイヤー衣服のような囲い付きアクセサリーは、WrapTargetとWrapLayerを使用してターゲットのModelの上に伸ばし包みます。レイヤーアクセサリーは、標準のR15 Robloxキャラクターでも非R15モデルでも機能します。
ユニークなケージUVマップを使用するモデルのようなレイヤー衣服のカスタム実装は、マーケットプレイスにアップロードして公開することはできません。詳細については、レイヤード衣服の仕様を参照してください。
アバターR15リグにレイヤーアクセサリーを実装する場合でも、カスタムリグを使用する場合でも、アクセサリーとボディには以下が含まれていることを確認してください:
- ターゲットモデル(通常は体)は、追加のモデルが包むことを意図したメッシュ上にWrapTargetコンポーネントを持っている必要があります。
- レイヤリングモデル(通常は衣服またはアクセサリー)は、ターゲットモデルを包むことを目的としたメッシュ上にWrapLayerコンポーネントを持っている必要があります。
- ターゲットモデルの外部ケージ、およびレイヤリングモデルの内部および外部ケージは、UVマップが一致している必要があります。
- ターゲットケージの対応する頂点は、レイヤーケージのそれらの頂点と同じUVを持つべきです。
- ターゲットモデルがR15で、Humanoidを含む場合、このウェルドは自動的に作成されます。