How to turn towards a part with BodyGyro given a turn rate

To achieve proportional navigation on missiles, I will have to apply a turn rate so that the missile will turn towards a target in a given rate.
I have already found out the way to calculate the turn rate but I don’t know how to apply it while considering the target’s position. How can I do it ?

1 Like

The wiki reads:

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

You should be able to choose the desired orientation with

missile.BodyGyro.CFrame = CFrame.new(missile.Position, targetPart.Position)

This will not update as the missile moves, so you want this line to run in a loop, or attached to an event like RunService.Heartbeat

Note that BodyGyro is deprecated, and it’s recommended to use AlignOrientation instead.

1 Like