Hello devoforum, I am trying to limit how up a plane can rotate. The problem is the angle, it keeps bouncing:
https://gyazo.com/5df7765bc0f8e3a5ffc625c807aa3477
https://gyazo.com/896e5d05e4359279bea6d8c868ee27b1
This is the code I am using:
local oriEntation = planeModel.Body.Orientation.X
local minMax = math.clamp(oriEntation, -55, 55)
if minMax == oriEntation then
local goDir = planeModel.Body.CFrame.LookVector
local mousePosition = GetMouseHit(workspace)
local velMaxF = Vector3.new(400000, 400000, 400000)
local bGyroMaxT = Vector3.new(900000, 900000, 900000)
local bGyroD = planeModel.Configs.Maneuvrability.Value
onEvent:FireServer(mousePosition, planeSpeed, goDir, planeModel.Body, velMaxF, bGyroMaxT, bGyroD)
elseif minMax == 55 then
planeModel.Body.CFrame = CFrame.new(planeModel.Body.Position) * CFrame.Angles(math.rad(54), math.rad(planeModel.Body.Orientation.Y), math.rad(planeModel.Body.Orientation.Z))
elseif minMax == -55 then
planeModel.Body.CFrame = CFrame.new(planeModel.Body.Position) * CFrame.Angles(math.rad(-56), math.rad(planeModel.Body.Orientation.Y), math.rad(planeModel.Body.Orientation.Z))
end
Thanks for reading.