BodyGyro Torque acting on world axis instead of local?

Hi! I’ve been working on a mountain biking game for several years, but after the advent of the new physics engine becoming standard, I’ve had some strange issues. What i’m trying to do is what I thought would be simple, but has turned into a major headache. I’m trying to keep the bike stable and have a tendency to want to be upright, as a bike would, but allow leaning when turning and being pliable, as a bike would. I’m using a BodyGyro to achieve this, setting the CFrame of it to basepartcframe.p, basepartcframe.p + basepartcframe.lookvector. This seems all fine and dandy but a peciliure thing is happening with my max torque which I can’t figure out. It appears as if though, instead of working on a local axis around the cframe, the torque is working on a global axis and it’s very difficult to control the bikes since I can’t tune each axis of rotation relative to the bike.

here’s the relevant code inside the bike

baseGyro.cframe = CFrame.new( baseCF.p, baseCF.p + baseCF.lookVector)
baseGyro.maxTorque = Vector3.new(math.abs(baseCF.lookVector.X*0.05),math.abs(baseCF.lookVector.Y*5),math.abs(baseCF.lookVector.Z*2.5)) * 38.5 --0.1,8,4,29.5

and a gif of the resulting issue:
Gif of the bike behaving strangely.
(there is a seperate tilting mechanic, using a body thrust that moves its location from side to side to tug on the bike. i’m doing the same thing facing one way, then another.)

Note in the code, the x and z axis of the torque being applied is two different values, but it translates onto a world axis instead of local to the BodyGyros CFrame.
I’ve tried to re-code it, set it to basic values (100,100,100), asked around for help and i’ve searched endlessly for the past few days for answers or a different way to code what I’m trying to code. Is there something i’m doing wrong here that I haven’t figured out in my torque code, i don’t understand why it’s behaving like this. I never had this problem before in legacy physics.

1 Like