Empty
Empty
Empty
Roblox 물리학을 통해 개발자는 게임 내에서 현실적인 상호작용과 움직임을 만들 수 있습니다. 물리학 요소를 이해하고 조작하는 것은 게임 플레이와 몰입도를 크게 향상시킬 수 있습니다.
구성 요소 | 설명 | 사용 사례 |
---|---|---|
BodyForce | 부품에 일정한 힘을 가합니다. | 지속적인 추력을 시뮬레이션, 예를 들어 로켓 엔진. |
BodyVelocity | 가해지는 힘을 조정하여 지정된 속도를 유지합니다. | 차량이나 플랫폼이 일정한 속도로 이동하도록 유지. |
BodyPosition | 부품을 지정된 위치로 이동하고 거기에 유지합니다. | 엘리베이터처럼 목표 위치로 이동하고 유지하는 부품 만들기. |
BodyGyro | 토크를 사용하여 부품의 방향을 유지합니다. | 로켓을 수직으로 유지하는 것처럼 부품의 회전을 안정화. |
BodyAngularVelocity | 부품에 일정한 회전 속도를 가합니다. | 회전 팬처럼 부품을 일정한 속도로 회전시키기. |
기본 물리학 예시
BodyVelocity
이 구성 요소는 특정 방향으로 일정한 속도를 유지하기 위해 지속적인 힘을 가하여 부품에 작용하는 다른 힘을 무효화합니다.
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
속도
이는 초기 상향 속도를 설정합니다. 속도는 중력 및 마찰과 같은 외부 힘으로 인해 시간이 지남에 따라 감소합니다.
Roblox Studio
local parentPart = script.Parent -- Reference to the parent part
parentPart.Velocity = Vector3.new(0, 50, 0) -- Move upward
BodyForce
이 구성 요소는 특정 방향으로 지속적인 힘을 가하여 중력을 상쇄하거나 지속적인 가속을 시뮬레이션하는 데 자주 사용됩니다. BodyVelocity와 달리, 이는 직접적으로 속도를 제어하지 않으며, 대신 일관된 힘을 가하여 이동에 영향을 미칩니다.
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
이 구성 요소는 부품을 지정된 위치로 이동시키고 거기에 유지하기 위해 지속적인 힘을 가하여 외부 힘을 무효화합니다.
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
이 구성 요소는 부품을 지정된 위치로 이동시키고 그 위치에 유지하기 위해 지속적인 힘을 가하여 외부 힘을 무효화합니다.
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축을 중심으로 일정한 회전 속도를 유지하기 위해 지속적인 토크를 가하여 저항력을 무효화합니다.
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