I’m currently scripting the beginnings of a kart-racing game. Currently I can make the carts turn accurately when they are on level ground. I can’t, however, figure out how to accurately make them turn on surfaces such as walls or hills.
Intended behavior on level surface: https://streamable.com/c5h1ju
Turning behavior on slanted surface: https://streamable.com/oxt159
To be clear, the cart should look the same as it does on level surfaces as it does on slanted surfaces.
I’ve tried a couple different things. Most things either produce an identical half-solution similar to the one below or don’t work at all. I’ve looked up a couple different resources and I either didn’t understand it at all or it didn’t work.
Current solution which works on level surface but not slanted surfaces:
self.CFrame *= CFrame.Angles(0, self.InputVector.X*step*self.TurningRadius, 0)
but I’ve also tried:
local upv, theta = self.CFrame:ToAxisAngle()
self.CFrame = CFrame.fromAxisAngle(upv, theta + self.InputVector.X*step*self.TurningRadius)
which didn’t work at all https://streamable.com/ogczig
I want the vehicle to turn on the green axis in this picture:
and not like the green axis in this picture (which is currently how it is rotating)