Attachment/アタッチメント
Attachmentは、Partの中に置く位置と向きの目印です。制約の接続点や、ビームの端などに使えます。
接続点の位置と向きを設定する
| 設定 | 使いどころ |
|---|---|
Position |
親のPartを基準に、接続点の位置をずらす。 |
Axis と SecondaryAxis |
主軸(ローカルX軸)と副軸(ローカルY軸)で接続点の向きを決める。 |
新しいBaseplateの ServerScriptService に Script を追加します。次の例では、Partの中心から上に0.5スタッドずらした位置にAttachmentを作ります。
local part = Instance.new("Part")
part.Position = Vector3.new(0, 5, 0)
part.Anchored = true
part.Parent = workspace
local attachment = Instance.new("Attachment")
attachment.Position = Vector3.new(0, 0.5, 0)
attachment.Visible = true
attachment.Parent = part
動作を確かめる
プレイして、Explorerで Workspace → Part → Attachment を選択します。親のPartを動かすと接続点も一緒に動きます。Position はPartを基準にした座標で、WorldPosition はワールド全体での座標です。制約が意図した方向へ動かない場合は、接続点の位置と軸を表示して見比べます。