I’m having an issue with BodyGyro where I have a ship and trying to make a wobble effect when it goes left to right. I managed to get an effect going, but when I turn the ship 180 degrees the wobble effect switches sides (video below). It’s also a little buggy because if the ship is moving forward for a couple seconds it starts to steer off course to the left or right and I cant figure out why.
The ships rudder is green in the video and the bodyGyro(D = 100, Torque = (0, 0, inf), P = 500) is on the rudder. The ship also moves forward with a VectorForce on the forward vector.
snippet of the turning right code
local function goRight(actionName, inputState)
if inputState == Enum.UserInputState.Begin then
--setting the bodyGyro
character.Rudder.BodyGyro.CFrame = character.Rudder.BodyGyro.CFrame * CFrame.Angles(character.Rudder.BodyGyro.CFrame.X, character.Rudder.BodyGyro.CFrame.Y, math.rad(10))
-- If the player holds down the button, turn right
connectionRight = runService.Heartbeat:Connect(function(dt)
character.Rudder.CFrame = character.Rudder.CFrame * CFrame.Angles(0, math.rad(1) * dt * -60, 0)
end)
--when the player stops holding the D key, it stops turning the ship to the right and balances the ship back into the middle.
elseif inputState == Enum.UserInputState.End then
character.Rudder.BodyGyro.CFrame = character.Rudder.BodyGyro.CFrame * CFrame.Angles(character.Rudder.BodyGyro.CFrame.X, character.Rudder.BodyGyro.CFrame.Y, -math.rad(10))
connectionRight:Disconnect()
end
end
Hmmm. There are a lot of ways, but off the top of my head you could do something like this:
Make the “rudder”/“engine” part handle physics, movement and steering with a BodyForce/BodyPosition and a BodyGyro (apply MaxTorque on the Y-axis only though!)
Make the actual visual part of the ship handle tilting with a separate BodyGyro (X/Z-axis only)
Then you need to attach the visual part to the engine part somehow without hindering the affected part’s BodyGyro’s ability to tilt.
You could probably use some constraints for that (maybe an AlignPosition and AlignOrientation+PrimaryAxisOnly). Or you could use RunService.Stepped and set the CFrame if you’re careful about how you go about it.