BodyGyro issues when coming too close to an object

Hello everyone. I have issues with my BodyGyro, as when my artillery comes too close to a soldier, this is what happens:

Any way to fix this?

1 Like

It’s hard to say. Can you share the code?

Are you rotating the artillery on its X and Z axes to face the target? I think you should only be using a force on the Y axis to rotate the cannon.
Your BodyGyro should still have forces on these axes so it keeps the artillery level.

Yeah, that’s what it does, here’s my code for rotating:

local bodygyro = troop.Torso:FindFirstChild("BodyGyro") or"BodyGyro") --bodygyro in order to turn the artillery in the enemy's direction
bodygyro.MaxTorque =,400000,400000)
bodygyro.P = 9000
bodygyro.D = 500
bodygyro.Parent = troop.Torso
bodygyro.CFrame =,, 0, enemy.Torso.Position.Z)) --turning at the troop

Maybe change the BodyGyro’s max torque?

Try changing
bodygyro.MaxTorque =,400000,400000)
bodygyro.MaxTorque =,400000,0)

Okay, I will try. Seems to work.
EDIT: Thank you so much!

1 Like