Cylindrical/円柱形
CylindricalConstraintは、直線のスライドと回転を組み合わせる制約です。伸縮しながら向きを変える仕掛けに使えます。
このページの目次
動きの例
Studioで試す
新しいBaseplateを開き、ServerScriptService に Script を作って次のコードを入れ、Playで試します。
local anchor = Instance.new("Part")
anchor.Name = "Anchor"
anchor.Size = Vector3.new(1, 1, 1)
anchor.Position = Vector3.new(0, 18, 0)
anchor.Anchored = true
anchor.Parent = workspace
anchor.CanCollide = false
local block = Instance.new("Part")
block.Name = "Block"
block.Size = Vector3.new(2, 3, 1)
block.Position = Vector3.new(0, 18, 0)
block.Parent = workspace
local a0 = Instance.new("Attachment", anchor)
a0.Orientation = Vector3.new(0, 0, 90)
local a1 = Instance.new("Attachment", block)
a1.Orientation = a0.Orientation
local cylinder = Instance.new("CylindricalConstraint")
cylinder.Attachment0 = a0
cylinder.Attachment1 = a1
cylinder.InclinationAngle = 0
cylinder.LimitsEnabled = true
cylinder.LowerLimit = -8
cylinder.UpperLimit = 0
cylinder.Parent = anchor
block.AssemblyAngularVelocity = Vector3.new(0, 3, 0)
動く範囲を制限する
| 制限したい動き | 設定 |
|---|---|
| 軸に沿った移動 | LimitsEnabled をオンにし、LowerLimit と UpperLimit を設定します。 |
| 軸まわりの回転 | AngularLimitsEnabled をオンにし、LowerAngle と UpperAngle を設定します。 |
回転軸の傾きを調整する
InclinationAngleは、回転軸の方向を、Attachment0のX/Y平面におけるX軸からの角度として、-180から180の範囲で定義します。これにより、スライド軸を変更せずに回転要素を傾けることができます。
Roblox公式の CylindricalConstraint リファレンス
動作を確かめる
プレイすると、Blockは回りながら下がり、8スタッドの位置で移動が止まります。例のBlockは最初に角速度を与えています。回し続けたい仕掛けは AngularActuatorType を Motor にして駆動できます。