Get plane to rotate past certain point

Hey everyone, I am trying to create a plane system and this is my code so far:

AlignOrientation.CFrame = CFrame.Angles(-pitch,-yaw,-yaw * math.rad(60))

(pitch and yaw are the mouse’s y and x respectively, both being numbers between -1 and 1)

The plane currently can only rotate up to a certain point, and I would know how I would be able to get it to rotate further

Roblox’s CFrame.Angles(-pitch,-yaw,-yawmath.rad(60)) will only rotate the plane between -1 and 1 radians in each direction, which is about -57.3 to 57.3 degrees, but if you want a full rotation (360 degrees or 2pi radians), you might need to scale those pitch and yaw values. If the maximum pitch and yaw you’re getting from your mouse input is 1 (which in Roblox probably corresponds to a full screen width of mouse movementleft/right or up/down) and you’d like to be able to rotate the plane a full circle (360 degrees or 2pi radians) with a full screen width of mouse movement, you can multiply the pitch and yaw values by 2pi. That means instead of -1 to 1 (about -57.3 to 57.3 degrees), you’re getting -2pi to 2pi (-360 to 360 degrees).

Update your code to:

AlignOrientation.CFrame = CFrame.Angles(-pitch * 2 * math.pi, -yaw * 2 * math.pi, -yaw * 2 * math.pi * math.rad(60))

This will allow a full 360 degree rotation with full screen width or height of mouse movement. If that’s too sensitive (i.e., moves the plane too quickly), you can adjust the multiplier (2*pi in this case) to get the right sensitivity. Also, ensure that pitch/yaw mouse’s y and x are updated in a way to cover the full -1 to 1 range for a full screen width/height of mouse movement to allow a full rotation.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.