「Prismatic/プリズマティック」は PrismaticConstraint というものに該当します。これは Robloxの制約の一つで、2つの物体間の1次元的な直線運動を可能にします。他の方向の運動(回転含む)は制限されます。この制約は、引き出し、エレベーター、スライダーなど、特定の軸に沿って直線運動する物体のシミュレーションに使用されます。

以下に、PrismaticConstraint を使用して作成したエレベーターのプログラム例を示します。このプログラムは単独で動作しますので、Workspace もしくは ServerScriptService に入れて実行してください。

— エレベータープラットフォームとアンカーポイントを作成
local platform = Instance.new(“Part”, workspace)
platform.Size = Vector3.new(5, 1, 5)
platform.Position = Vector3.new(0, 20, -3)
platform.Name = “Platform”

local anchor = Instance.new(“Part”, workspace)
anchor.Anchored = true
anchor.Size = Vector3.new(1, 1, 1)
anchor.Position = Vector3.new(0, 20, 0)
anchor.Name = “Anchor”

— PrismaticConstraintを作成
local prismaticConstraint = Instance.new(“PrismaticConstraint”)
prismaticConstraint.Parent = anchor

local attachment0 = Instance.new(“Attachment”, anchor)
local attachment1 = Instance.new(“Attachment”, platform)
attachment0.Position = Vector3.new(0,0.5,-0.5)
attachment1.Position = Vector3.new(0,0.5,2.5)
attachment0.Axis = Vector3.new(0,1,0)
attachment1.Axis = Vector3.new(0,1,0)
prismaticConstraint.Attachment0 = attachment0
prismaticConstraint.Attachment1 = attachment1

prismaticConstraint.Enabled = true
prismaticConstraint.ActuatorType = Enum.ActuatorType.Servo — サーボとして動作
prismaticConstraint.ServoMaxForce = 10000 — サーボの最大力
prismaticConstraint.Speed = 10 — 移動速度
prismaticConstraint.UpperLimit = 0 — 上方向の移動限界
prismaticConstraint.LowerLimit = -20 — 下方向の移動限界
prismaticConstraint.LimitsEnabled = true
prismaticConstraint.TargetPosition = -20 — 一番下まで移動(初期値として設定)

このプログラムは、エレベータープラットフォームとアンカーポイントを作成し、PrismaticConstraint を使って上下できるようにしています。TargetPositionを指定することにより、好きな位置に止めることが可能です。上記の例では-20から0の範囲で指定することができます。
これを拡張することにより、各階に停止するエレベータが作成できると思います。

Linear Power

ActuatorTypeがMotorに設定されている場合、Velocityに到達することを目標にアタッチメントを並進させようとします。MotorMaxAccelerationとMotorMaxForceの両方で、この平行移動をコントロールできます。
ActuatorTypeがServoに設定されている場合、TargetPositionで指定された設定されたセパレーションにアタッチメントを平行移動させようとします。この移動は、Speed、LinearResponsiveness、ServoMaxForceによって制御されます。

By schilverberch

ROBLOXでゲームを作ろう! 一緒にプログラミングを学びましょう。

コメントを残す