I’m making a mouse-controlled plane system utilizing AlignOrientation and LinearVelocity. Problem is, when I move my mouse all the way downwards or upwards, it goes all crazy as shown in the video:
I want to be able to go upside down without any problem.
Here’s my code if you need it.
local dir = (currentmouse.Hit.Position - cam.CFrame.Position).Unit
local aim = CFrame.new(cam.CFrame.Position, cam.CFrame.Position + dir)
local aimdirection = aim * CFrame.Angles(0,0,math.rad(clampAngle(roll + yawtween.Value))) -- this handles rolling left and right
-- i tried to set a max angle going downwards and upwards here, didnt help
local maxangle = 80
local rx,ry,rz = aimdirection:ToOrientation()
local xlimit = math.clamp(math.deg(rx),-70,70)
local fromor = CFrame.fromOrientation(math.rad(xlimit),ry,rz)
local aimdirectionfinal = CFrame.new(aimdirection.Position) * fromor
ship.Important.Events.Orientation:FireServer(aimdirectionfinal)```
This new code should correctly limit the rotation angle around the x-axis to a maximum of maxangle degrees in either direction because you were technically doing a mistake in the code
oh and btw don’t forget to initialize the maxangle