Before I get started, I know you are all going to say “BodyGryos are deprecated.” This is true, but I am using them in this system, so I need help with it.

I have a piece of code that both turns the spaceship and makes it roll a little, to add a cool turning effect. However, when I use this code, it is very jerky. I can’t use tweens because the ship is not anchored. I also can’t use the same BodyGyro that turns the ship because then it affects the turning of the ship. I have experimented with using several BodyGyros, but that doesn’t work either. All help appreciated!

Snippet in question:

if spaceship.Steer > 0 then
spaceship.BodyGyro.CFrame = CFrame.fromEulerAnglesXYZ(0, 0, -10)
spaceship.BodyGyro.CFrame = spaceship.BodyGyro.CFrame * CFrame.fromEulerAnglesXYZ(0, -0.1, 0)
elseif spaceship.Steer < 0 then
spaceship.BodyGyro.CFrame = CFrame.fromEulerAnglesXYZ(0, 0, 10)
spaceship.BodyGyro.CFrame = spaceship.BodyGyro.CFrame * CFrame.fromEulerAnglesXYZ(0, 0.1, 0)
elseif spaceship.Steer == 0 then
spaceship.BodyGyro.CFrame = CFrame.fromEulerAnglesXYZ(0, 0, 0)
spaceship.BodyGyro.CFrame = spaceship.BodyGyro.CFrame
end

Hey there! Im not a scripted, but this could help.

Try using the RenderStepped event to gradually interpolate the rotation of your spaceship. This approach can help you achieve smoother turning without affecting the overall ship rotation.

local spaceship = -- whatever your ship name is called
local BodyGyro = spaceship:FindFirstChild("BodyGyro")
local turnRate = 0.1 -- adjust for turning speed
local function updateRotation()
if spaceship.Steer > 0 then
spaceship.BodyGyro.CFrame = spaceship.BodyGyro.CFrame:lerp(CFrame.Angles(0, 0, -10), turnRate)
elseif spaceship.Steer < 0 then
spaceship.BodyGyro.CFrame = spaceship.BodyGyro.CFrame:lerp(CFrame.Angles(0, 0, 10), turnRate)
else
spaceship.BodyGyro.CFrame = spaceship.BodyGyro.CFrame:lerp(CFrame.new(), turnRate) -- Reset rotation
end
end
-- connect to the RenderStepped event for smothe update
game:GetService("RunService").RenderStepped:Connect(updateRotation)

^ I used the RenderStepped event to gradually interpolate the rotation using the lerp function. This should make the turning effect smoother. Remember to adjust the turnRate to control the speed of the turning effect as needed. Cheers!

You know, im no scripter but I actually am getting the hang of code.

Yeah, it doesn’t nose up/down, just one plane, and then up/down buttons. I would prefer not rewriting everything and using tweens, they dont react well to the physical environment.

The reason why it’s unstable is because roblox didn’t intend to support the use two BodyGyros so therefore I think the only way to this would be to integrate the roll with the main turning system.

This works great for smooth animation, thanks! However, I also need to actually turn the ship. For example, I need to do the roll just for animation, but I also need to change the Y by 0.1 to actually turn the ship, outside of control of the animation. I tried this, but it doesn’t turn, only the anim plays:

local spaceship = workspace:FindFirstChild("YourShipName") -- replace 'YourShipName' with the actual name of your ship in the workspace
local BodyGyro = spaceship:FindFirstChild("BodyGyro")
local turnRate = 0.1 -- adjust this value for turning speed
local turnAmount = 0.1 -- adjust this value for turning the ship
local function updateRotation()
if spaceship and spaceship.Steer then
if spaceship.Steer > 0 then
local rotation = CFrame.Angles(0, 0, -10) * CFrame.Angles(0, turnAmount, 0)
spaceship.BodyGyro.CFrame = spaceship.BodyGyro.CFrame:lerp(rotation, turnRate)
elseif spaceship.Steer < 0 then
local rotation = CFrame.Angles(0, 0, 10) * CFrame.Angles(0, -turnAmount, 0)
spaceship.BodyGyro.CFrame = spaceship.BodyGyro.CFrame:lerp(rotation, turnRate)
else
spaceship.BodyGyro.CFrame = spaceship.BodyGyro.CFrame:lerp(CFrame.new(), turnRate) -- reset rotation
end
end
end
game:GetService("RunService").RenderStepped:Connect(updateRotation)

local spaceship = workspace:FindFirstChild("YourShipName") -- replace 'YourShipName' with the actual name of your ship in the workspace
local BodyGyro = spaceship:FindFirstChild("BodyGyro")
local animationRate = 0.1 -- adjust this value for animation smoothness
local turnAmount = 0.1 -- adjust this value for turning the ship
local function updateRotation()
if spaceship and spaceship.Steer then
if spaceship.Steer > 0 then
spaceship.BodyGyro.CFrame = spaceship.BodyGyro.CFrame:lerp(CFrame.Angles(0, 0, -10), animationRate)
local rotation = CFrame.Angles(0, math.rad(turnAmount), 0)
spaceship.CFrame = spaceship.CFrame * rotation
elseif spaceship.Steer < 0 then
spaceship.BodyGyro.CFrame = spaceship.BodyGyro.CFrame:lerp(CFrame.Angles(0, 0, 10), animationRate)
local rotation = CFrame.Angles(0, math.rad(-turnAmount), 0)
spaceship.CFrame = spaceship.CFrame * rotation
else
spaceship.BodyGyro.CFrame = spaceship.BodyGyro.CFrame:lerp(CFrame.new(), animationRate) -- reset animation
end
end
end
game:GetService("RunService").RenderStepped:Connect(updateRotation)