Can you break down X and Z into X, Y, Z trigonometric components?

local x, y, z = 0, 0, 0
		if cv.injump then
			--	print("We are rolling! ")
			-- if my cart is rolled to the side by 45 degrees.
			-- if my desired pitch is 45 degrees.
			-- then 
			-- y should point slightly to the right, 
			-- x should point slightly up,
			-- z should point slightly to the side yknow.
			x,y,z = cv.DesiredPitch, 0, cv.DesiredRoll
			warn("Pitch, ", math.deg(x), "  Roll, ",math.deg(z))
			
			-- x and z have components that should be used to adjust y,
			-- this will let the cart perform better stunts and backflips.
		end
		if cv.AddVelX.Magnitude > 1 and prevface then 
			cv.face = prevface
		end
		cv.DesiredCF = cv.face.CFrame * CFrame.Angles( ((cv.flight and math.rad(6)) or 0) + cv.PitchAngle , cv.YawAngle, cv.Angle) *  CFrame.Angles(x, y, z)

This is for my game downhill rush.

What the game is meant to do is, players can perform jumps if they go on ramps.

if they are in a jump then therei s a button that lets them increase or decrease the DesiredPitch and DesiredRoll

The problem is that if I roll my cart 90 degrees and try to pitch upwards the car starts yawing sideways as it is not supposed to.
What is intended is
When the cart is rolled 90 degrees then me pitching up should cause the ‘y’ variable to be changed.
When the cart is pitched up by 90 degrees then me trying to roll the cart should cause the ‘y’ variable to be changed too idk

1 Like

Instead of XYZ rotations, I suggest you use pure CFrames and specifically CFrame.fromAxisAngle(rotationVector, angle)
XYZ can be a headache at best and it doesn’t contain enough information to properly describe rotation.

2 Likes

Sounds like you are hitting ‘gimbal lock’ at 90 degrees.
I’ve heard that using a CFrame.fromAxisAngle or quaternions solves the issue.
This post Y and Z adding together in orientation may help.

2 Likes

Feels like you missed the point,

the x, y, z, variables are in radians.

1 Like

That is exactly what i am doing, X, y, z uses radians.

I just want it so
cv.DesiredPitch and cv.DesiredRoll can be combined into x, y, z radian values

1 Like

Radians aren’t the issue, the issue is that Euler angles (XYZ rotations) don’t contain enough data. You can’t fully describe the rotation of an object using only X, Y, and Z. You need to use either quaternions (WXYZ rotations) which I’m not personally familiar with, or use rotation matrices like CFrames. Don’t touch XYZ rotations.

Scottifly was saying the same thing.

What you want to do is take a starting CFrame and then multiply it by one or more CFrame.fromAxisAngle of a certain axis and a certain angle. This will give you proper control over what order the rotations are applied in and you won’t experience gimbal lock or other issues that occur with XYZ rotation.

2 Likes

As @JarodOfOrbiter said, it’s not a radians/degrees issue.
You are still hitting gimbal lock at 1.5708 radians or 90 degrees.

Can we just do this

If the cv.DesiredRoll is 90 degrees or pi/2 radians then
the y variable = cv.DesiredPitch the x variable becomes 0 – so im guess x relies on cosine of roll
if the desiredroll is 45 degrees then
the y variable and the x variable are the same but they are both the sin 45 of cv.DesiredPitch

get it?

1 Like

Here’s another post that deals with a similar issue. Math.atan2 on the Y performing weirdly - #7 by Scottifly

I’m afraid I don’t get it. I’m just not personally familiar with Euler angles or 3D trigonometry. I don’t use XYZ rotations and (as I’ve mentioned above) I definitely don’t use WXYZ rotations. If you want help revising it to rely on rotation matrices and FromAxisAngle, I’m totally your guy though.

If that’s the route you want to go, you’ll need to stop talking to me in xyz rotations - I’m just not competent enough with them to understand what they mean or what you’re doing with them. My assumption is you’ve got an object (a car, plane, character, whatever) and you’re trying to make the pitch-forward control (and other controls) always either
a) pitch forward in local space, acting like the controls on an airplane, or
b) pitch forward in camera space, acting to rotate the visible top of the object away from the camera.
Let me know (without using xyz) what you want this object to behave like and I’ll give you some easy examples.


Or, if you still want to use trigonometry and Euler angles, good luck. I can’t help with them and I don’t know of any solutions for your issue other than using Quaternions (which I am even less familiar with.) I hope you get it working.

1 Like