PcoWSkbVqDnWTu_dm2ix
We use cookies on this site to enhance your user experience
Collapse Sidebar

BodyGyro

Show deprecated

BodyGyro

Show deprecated

The BodyGyro object applies a torque (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. Essentially, it’s 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, and BodyGyro/D|D controls dampening behavior.

Setting the Orientation

Like all DataType/CFrame properties, the BodyGyro/CFrame property isn’t editable in the Properties window of Studio. Since there’s no physical component to a BodyGyro, you should use scripting to set the BodyGyro/CFrame.

A common technique for setting the goal orientation is to set the BodyGyro/CFrame to a part’s BasePart/CFrame|CFrame. For example:

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

You can also use a DataType/CFrame constructor which initializes rotation such as CFrame.fromAxisAngle, CFrame.fromEulerAnglesXYZ, or CFrame.fromEulerAnglesYXZ. Alternatively, you can use the following structure to make the body gyro “look at” a targetPosition.

CFrame.new(BodyGyro.Parent.Position, targetPosition)

Troubleshooting

  • If the assembly isn’t moving at all, it 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 the assembly isn’t moving on all axes, double check the axis in question has sufficient BodyGyro/MaxTorque|MaxTorque. Alternatively, if the part allows movement on an axis and shouldn’t, be sure the BodyGyro/MaxTorque|MaxTorque is non-zero on that axis and refine the manner in which you are setting the BodyGyro BodyGyro/CFrame|CFrame.
  • If the assembly is moving too quickly, consider raising the BodyGyro/D|D (dampening) property.
  • If the assembly 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.
  • Any assembly containing a part that contains a BodyGyro or BodyPosition will not be simulated when interacting with a player unless that player is the /articles/Network Ownership|network owner of the assembly.

Properties

CFrame

CFrame

Determines the target orientation (translational component ignored)

float

D

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

Vector3

MaxTorque

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

float

P

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

Functions

Events