Struggling to Rotate an Object by Local Axis

Hey guys. I’ve been banging my head into a wall for the past while, because I can’t seem to rotate a tire by both yaw (y axis) and pitch (x axis, think look vector angularity). Yaw works fine, but pitch only works when the lookVector of the yaw is aligned with the global x axis. When it’s perpendicular for example, it causes the tire to do a barrel roll. I could easily see this was because the cframe was rotating the pitch globally, not respecting the object’s yaw.

local cf = CFrame.Angles(throttle, yaw,0)

This is what I had before trying to fix it. I’m assuming my inept knowledge of how cframe rotation works is the flaw behind this

So I tried

local cf = CFrame.new(position) * CFrame.Angles(0,steer,0)
cf *= CFrame.Angles(throttle,0,0)

and

local cf = CFrame.new(position) * CFrame.Angles(0,steer,0)
cf *= CFrame.fromAxisAngle(cf.RightVector, throttle)

both still rotate the pitch globally!
If any of yall have a clue on how to actually rotate something while respecting its already rotated cframe, please let me know <3
Thanks!

Well the order at which you apply the rotation matters because they are not necessarily commutative. If you apply the pitch first then the yaw it should work.

2 Likes

That’s what I thought too, but it still seems to have the same issue
The fundamental issue here is that euler angles don’t have independent values for each axis of rotation, but that’s exactly what I need. And I don’t know how to compute such a thing :sad_but_relieved_face:

local cf = CFrame.new(position) * CFrame.Angles(0,steer,0)
cf *= CFrame.Angles(throttle,0,0)

Are you sure your original method didn’t work? It seems to work for me.
I forgot that it’d actually apply the transformations from right to left so yours would apply pitch first.

1 Like

ok yeah it looks like its a rotation order problem, thanks!