BodyGyro controlled plane freaks out when you're heading straight up or down?

A couple of days ago, I finished a plane system in my game that would allow the player to control a biplane and have an immersive experience.

However, after some testing with my friends, I found a fatal flaw that could potentially kill the immersion of the plane itself.

Here’s a visual demonstration on how this “issue” works.
https://streamable.com/jihzny

As you can see, the plane will begin to freak out once they’re headed up or down. I’ve searched the internet and scoured each devforum post but to no avail.

I have ZERO clue on why this happens, but I think it might be because of the gravity? Or perhaps some other physics force weighing down on the plane and making it spazz out.

Please help, this issue has plagued me for days now. Any help is appreciated :))))

1 Like

i think you should divide the y axis of the mouse on the body gyro

idk your code, but do something like this to your body gyro:

bodygyro.CFrame = (mouse.Hit.x,mouse.Hit.y/1.5,mouse.Hit.z)

or something like this, it will make it so that your plane can’t be aimed straight up, which stops the body gyro from having a spaz

Hi!

Sorry for the late response, I will immediately try this out! Thanks for replying my man! :))))

EDIT: It didn’t work… :frowning:

can you show the part where you index the bodygyro’s cframe

This is the code:

body.BodyGyro.CFrame = cfNew(body.Position, v3(pos.X, pos.Y/2, pos.Z))

Keep in mind that “pos” is mouse.Hit.Position
v3 is also a shortened version of Vector3.new just because it’s easier to understand (at least for me)

try adding it?

body.BodyGyro.CFrame = cfNew(body.Position, body.Position + v3(pos.X, pos.Y/2, pos.Z))

i made a mouse script that makes the player look at the mouse and stop them from looking up to avoid going helicopter

Gyro.CFrame = CFrame.new(Root.Position, Root.Position + Vector3.new(mouse.Hit.lookVector.x, 0, mouse.Hit.lookVector.z))
1 Like

Nope, still doesn’t help. The plane keeps nodding up and down. :(((

This issue has been around since the first planes were ever made on Roblox. The problem is caused by the way the BodyGyro’s CFrame is constructed. When you use the legacy two-Vector3 constructor the result is configured so that the “up vecctor” defaults at (0, 1, 0). So when you make a CFrame pointing straight up or straight down the cross product of the look vector and the initial up vector is close to zero which makes it seem buggy.

As an alternative you can use the new CFrame.lookAt constructor which lets you specify an ‘up’ vector; in your case maybe using the upVector of the plane body’s current CFrame could prevent that ‘jerking’ motion.

1 Like

Could you give me an example of how to use .lookAt and how I would use UpVector to fix this problem?

body.BodyGyro.CFrame = CFrame.lookAt(body.Position, v3(pos.X, pos.Y/2, pos.Z), body.CFrame.UpVector)

No idea if this will work, though, but worth a shot.

Alright so that code KINDA worked, but there’s still a slight issue (well, kinda big actually)

When I start heading up, the plane will randomly move to the side and dive straight down, before immediately jerking back to its original rotation…