I’m working on a flight system that I ideally wish to have restrictions:-
I.e. When the Player is turning Left / Right, I want the ship to tilt on the X axis by a maximum of 45 Degrees on either side and when the Player is turning upwards or downwards, I want the ship to turn a maximum of 85 Degrees either side.
Currently I use the code shown below to determine the CFrame required however, it’s proven to be extremely.
local rot = CFrame.fromEulerAnglesXYZ(0,0,0)
BodyGyro.CFrame = (rot*(BodyGyro.CFrame-BodyGyro.CFrame.p)) + BodyGyro.CFrame.p
local x,y,z = BodyGyro.CFrame:ToOrientation()
BodyGyro.CFrame = CFrame.fromOrientation(math.rad(tiltAngleDiv), math.rad(TurnAngle), math.rad(turnAngleDiv))
if PilotSeat.Throttle == 1 then
if TiltIncline < 85 then
TiltIncline += 2
end
elseif PilotSeat.Throttle == -1 then
if TiltIncline > -85 then
TiltIncline -= 2
end
end
if PilotSeat.Steer == 1 then
TurnAngle -= 2
if Incline > -24 then
Incline -= 2
end
elseif PilotSeat.Steer == -1 then
TurnAngle += 2
if Incline < 24 then
Incline += 2
end
elseif PilotSeat.Steer == 0 then
if Incline > 0 then
Incline -= 2
elseif Incline < 0 then
Incline += 0.5
end
end
turnAngleDiv = Incline / turnInclineAngle
tiltAngleDiv = TiltIncline / tiltInclineAngle
When the Player enters Hyperspace - This code is ran the keep the variables the same when entering Hyperspace in whichever direction. However, it results in extreme shaking - Is there a more efficient way I can do this?
TiltIncline = Main.PrimaryPart.Orientation.X
tiltAngleDiv = TiltIncline / tiltInclineAngle
Incline = Main.PrimaryPart.Orientation.Z
turnAngleDiv = Incline / turnInclineAngle
TurnAngle = Main.PrimaryPart.Orientation.Y
Shaking is vague but noticeable if you look at the edge(s) of the Baseplate.