How do i make this CFrame rotate correctly?

So i was reworking this custom movement thing with my current knowledge.
And i ran into this ploblem i can’t seem to figure out. Look at how the torso rotates:

up/down is just fine
up_down

left/right (you can see the problem at this point):
left_right

but if you rotate 90° and look up and down it goes:
the_problem

This rotation happens in the Waist Motor6D and is controlled by the mouse. Basically it collects the mouse delta (position) to a Vector2 and then rotates based on that.

local rotationCorrected = CFrame.new() * CFrame.Angles(-math.rad(deltaTotal.Y), -math.rad(deltaTotal.X), 0)

^This is the part that’s messing up.

waist.C0 = CFrame.new(waist.C0.Position) * cf

^And this is just the server side. (i don’t want to calculate too much on server side because… big game)

Any help is appreciated.

Use CFrame.FromEulerAnglesYXZ() rather than CFrame.Angles
It applies the angles in a more natural order

That is not the problem. I think you might have misunderstood or i was not clear enough.
The problem is that it rotates on the same angles even if you rotate 90°.
If you check the third gif you can see that i look up and down, but it rotates sideways, but that sideways rotation is right if you look straight.

Basically it acts like i still look forward and rotates the Waist C0 as if i was looking forward.

Edit: So i think i just need to rotate the CFrame given by this function, so if i look up it rotates right.

CFrame.Angles:


CFrame.FromEulerAnglesYXZ:

1 Like

Ah yes, now i see what you ment.
Marked as solution and thank you for your time.

1 Like