Rotating BodyGyro on one axis only

I’m currently making a Nascar racing game and have been working on a car controller for a while now. I’ve only tested on flat ground, and now that I’m testing banking (Slightly elevated + angled ground) the car does fall flush against the bank.

Heres what i mean:
image

As you can see, the car’s tail end is floating instead of following. I think this is because of the BodyGyro updating to keep the orientation still.

What I need help with:
I need to figure out how to rotate BodyGyro on one axis (Y-axis) that is relative to the object’s space only.

What I’ve tried
I’ve tried using CFrame.FromOrientation instead, as well as BodyAngularVelocity (That fixes the problem, but creates a bunch of others too). I was going to try to use CFrame:ToObjectSpace() But I couldn’t figure out how to implement it into my code.

Here’s my code, in case it helps:

if seat.Steer > 0 then
		angle.CFrame = angle.CFrame * CFrame.Angles(0,math.rad(turnSpeed),0)
	elseif seat.Steer < 0 then
		angle.CFrame = angle.CFrame * CFrame.fromOrientation(0,math.rad(turnSpeed),0)
	elseif seat.Steer == 0 then
		angle.CFrame = angle.CFrame * CFrame.fromOrientation(0,0,0)
	end

(There’s more to the code, but I figured this is probably good enough for reference??)

Woops! Ignore the “FromOrientation” lines, those are supposed to be Angles, they’re from my testing phase lol

This is actually very simple.
Set the axes that you don’t use in BodyGyro.MaxTorque to 0

3 Likes

Oh wow, that hadn’t even crossed my mind! In an older project of mine i had to set all axis of BodyGyro to the same or it would go all wonky. Thanks!