We use cookies on this site to enhance your user experience

The BodyGyro object applies a torque (or rotational force) on a BasePart such that it maintains a constant angular displacement, or orientation. This allows for the creation of parts that point in a certain direction, as if a real gyroscope were acting upon it. It is the rotational counterpart to a BodyPosition. If you would like to maintain a constant angular velocity, use a BodyAngularVelocity instead.

The BodyGyro/CFrame|CFrame property controls the goal orientation. Only the angular components of the DataType/CFrame are used - position will make no difference. BodyGyro/MaxTorque|MaxTorque limits the amount of angular force that may be applied. BodyGyro/P|P controls the power used in achieving the goal orientation. Finally, BodyGyro/D|D controls dampening behavior.

Setting the Orientation (CFrame)

Like all CFrame-type properties, the BodyGyro/CFrame property isn’t editable in the Properties window in Studio. Since there’s no physical component to a BodyGyro, you should use the Command bar or another scripting method to set the CFrame. A common technique used to set the goal orientation is to use a part’s present orientation: simply set the BodyGyro/CFrame to the Part’s BasePart/CFrame|CFrame. For example:

workspace.Part.BodyGyro.CFrame = workspace.Part.CFrame

You can also use a CFrame constructor which initializes rotation, such as: CFrame.fromAxisAngle, CFrame.fromEulerAnglesXYZ or CFrame.fromEulerAnglesYXZ. Beware of gimbal lock as you decide on the method and angles (in radians). Additionally, you could use CFrame.new(gyro.Parent.Position, targetPosition) in order to have the BodyGyro “look at” a targetPosition.

Troubleshooting

  • If your part isn’t moving at all, the assembly most likely has mass larger than what the BodyGyro can move. Try raising the BodyGyro/MaxTorque|MaxTorque and/or BodyGyro/P|P (power) properties. You should also check that no BasePart/Anchored|Anchored parts are within the assembly or in the way of the assembly.

  • If your part isn’t moving on all axes, double check the axis in question has sufficient BodyGyro/MaxTorque. Alternatively, if the part allows movement on an axis and shouldn’t, be sure the MaxTorque is nonzero on that axis and refine the manner in which you are setting the BodyGyro’s BodyGyro/CFrame|CFrame.

  • If your part is moving too quickly, consider raising the BodyGyro/D|D (dampening) property.

  • If your part is moving too slowly, consider lowering the BodyGyro/D|D (dampening) property. Also consider raising the BodyGyro/MaxTorque|MaxTorque and/or BodyGyro/P|P (power) properties.

Properties

Name Type Description
CFrame

Determines the target orientation (translational component ignored)

D

float

Determines the amount of dampening to use in reaching the goal BodyGyro/CFrame|CFrame

Vector3

Determines the limit on how much torque that may be applied to each axis

P

float

Determines how aggressive of a torque is applied in reaching the goal orientation

Inherited from Instance , BodyMover

Archivable ClassName DataCost Name Parent RobloxLocked