Rigid Constraint/剛性拘束
RigidConstraint は、2つのAttachmentまたはBoneを接続して、固定した位置関係と向きを保ちます。部品の取り付け位置を接続点で指定するときに使います。
動きの例
Studioで試す
Attachment0 と Attachment1 に接続点を指定します。例では、固定したPartの下面と、その下に置くPartの上面に接続点を配置します。
新しいBaseplateを開き、ServerScriptService に Script を作って次のコードを入れ、Playで試します。
local anchor = Instance.new("Part")
anchor.Name = "Anchor"
anchor.Size = Vector3.new(4, 2, 4)
anchor.Position = Vector3.new(0, 12, 0)
anchor.Anchored = true
anchor.Parent = workspace
local block = Instance.new("Part")
block.Name = "Block"
block.Size = Vector3.new(2, 2, 2)
block.Position = Vector3.new(0, 10, 0)
block.Parent = workspace
local topPoint = Instance.new("Attachment", anchor)
topPoint.Position = Vector3.new(0, -1, 0)
local bottomPoint = Instance.new("Attachment", block)
bottomPoint.Position = Vector3.new(0, 1, 0)
local rigid = Instance.new("RigidConstraint")
rigid.Attachment0 = topPoint
rigid.Attachment1 = bottomPoint
rigid.Parent = anchor
2つの固定方法の使い分け
| 機能 | 接続先 | 選ぶ場面 |
|---|---|---|
| WeldConstraint | Part0とPart1 | 配置済みの2パーツを、その位置関係のまま固定するとき |
| RigidConstraint | Attachment0とAttachment1 | 接続点の位置と向きを基準に固定するとき |
Roblox公式の RigidConstraint リファレンス
動作を確かめる
プレイすると、下のPartは上のPartの下面に固定され、重力で落ちません。取り付け位置や向きがずれる場合は、各Attachmentの Position と Orientation を確認します。