基本物理

Robloxの物理エンジンは、開発者がゲーム内でリアルなインタラクションと動きを作成することを可能にします。物理コンポーネントを理解し、操作することで、ゲームプレイと没入感を大幅に向上させることができます。

コンポーネント説明使用例
BodyForceパーツに一定の力を加える。ロケットエンジンのような持続的な推力のシミュレーション。
BodyVelocity加えられた力を調整して、指定された速度を維持します。車両やプラットフォームを一定の速度で移動させ続ける。
BodyPositionパーツを指定された位置に移動させ、そこに留めます。エレベーターのように、ターゲット位置に移動し保持するパーツを作成する。
BodyGyroトルクを使用してパーツの向きを維持します。ロケットを直立させるなど、パーツの回転を安定させる。
BodyAngularVelocityパーツに一定の回転速度を加える。扇風機のように、パーツを一定の速度で回転させる。

基本物理の例

BodyVelocity

このコンポーネントは、特定の方向に一定の速度を維持するために継続的に力を加え、パーツに作用する他の力を無効にします。
Image 1
Roblox Studio
local parentPart = script.Parent -- Reference to the parent part

local velocity = Instance.new("BodyVelocity")
velocity.Velocity = Vector3.new(0, 50, 0) -- Move upward 
velocity.MaxForce = Vector3.new(0, 10000, 0) -- Apply force on Y axes
velocity.Parent = parentPart -- Apply the BodyVelocity to the parent part

速度

これは、初期の上向きの速度を設定します。重力や摩擦などの外力のため、時間とともに速度は減少します。
Image 1
Roblox Studio
local parentPart = script.Parent -- Reference to the parent part

parentPart.Velocity = Vector3.new(0, 50, 0) -- Move upward

BodyForce

このコンポーネントは、特定の方向に持続的な力を加え、通常は重力に逆らうか、一定の加速をシミュレートします。BodyVelocityとは異なり、速度を直接制御するのではなく、一貫した力を加えることで動きを制御します。
Image 1
Roblox Studio
local parentPart = script.Parent -- Reference to the parent part

local force = Instance.new("BodyForce")
force.Force = Vector3.new(0, 5000, 0) -- Apply upward force of 5000 on the Y-axis
force.Parent = parentPart -- Apply the BodyForce to the parent part

BodyGyro

このコンポーネントは、指定された位置にパーツを移動させ、そこに留めるために継続的に力を加え、外力を無効にします。
Image 1
Roblox Studio
local parentPart = script.Parent -- Reference to the parent part

local gyro = Instance.new("BodyGyro")
gyro.CFrame = CFrame.Angles(math.rad(45), math.rad(30), 0) -- Desired rotation
gyro.MaxTorque = Vector3.new(4000, 4000, 4000) -- Maximum torque applied on each axis
gyro.P = 3000 -- Power
gyro.Parent = parentPart -- Apply the BodyGyro to the parent part

BodyPosition

このコンポーネントは、指定された位置にパーツを移動させ、そこに留めるために継続的に力を加え、外力を無効にします。
Image 1
Roblox Studio
local parentPart = script.Parent -- Reference to the parent part

local position = Instance.new("BodyPosition")
position.Position = Vector3.new(0, 5, 0) -- Target position
position.MaxForce = Vector3.new(4000, 4000, 4000) -- Maximum force applied to reach the target position
position.D = 1000 -- Damping
position.P = 5000 -- Power
position.Parent = parentPart -- Apply the BodyPosition to the parent part

BodyAngularVelocity

このコンポーネントは、Y軸周りの一定の回転速度を維持するために継続的にトルクを加え、抵抗力を無効にします。
Image 1
Roblox Studio
local parentPart = script.Parent -- Reference to the parent part

local angularVelocity = Instance.new("BodyAngularVelocity")
angularVelocity.AngularVelocity = Vector3.new(0, 2, 0) -- Rotate around Y-axis
angularVelocity.MaxTorque = Vector3.new(0, 10000, 0) -- Maximum torque applied
angularVelocity.Parent = parentPart -- Apply the BodyAngularVelocity to the parent part

このチュートリアルがお役に立ちましたら、私の仕事をサポートするためにコーヒーをおごっていただけると嬉しいです。

ご支援、誠にありがとうございます!

コーヒーをおごる