Hi,
I’m looking for a way to tilt a Plane along a restricted X, Y, Z axis.
By this I mean:
The Plane is capable of turning left & right; upon doing so the Z axis will tilt the Plane but only by about (-25, 25) so that the tilt doesn’t affect the movement.
The Plane is also capable of moving up and down; upon doing so the X axis will tilt the Plane on a desired angle (-85, 85) So that the Plane never faces directly up or down.
My current method as shown below rounds the Rotation etc. to the nearest multiple of 2.5 allowing it to keep a smooth motion - HOWEVER; this show obvious rotations etc as the Plane is starting / ReCalculating as it’s moving from PointA to PointB.
Does anyone have any ideas on how I can achieve what I’m looking for?
This is currently what I have from the script provided -Though surely there has to be another way I can achieve this?
Module.Round = function(x)
local divided = x / MaxTurn
local rounded = MaxTurn * math.floor(divided)
return rounded
end
BodyVelocity.Velocity = Main.PrimaryPart.CFrame.LookVector * Speed
BodyGyro.CFrame = CFrame.new(Main.PrimaryPart.CFrame.p)
* CFrame.Angles(0, math.rad(Rotation.Y), 0)
* CFrame.Angles(math.rad(Rotation.X), 0, 0)
* CFrame.Angles(0, 0, math.rad(Rotation.Z))
if PilotSeat.Throttle == -1 then
if Rotation.X > -85 then
Rotation.X -= MaxTurn
end
elseif PilotSeat.Throttle == 1 then
if Rotation.X < 85 then
Rotation.X += MaxTurn
end
end
if PilotSeat.Steer == -1 then
Rotation.Y += MaxTurn
if Rotation.Z < 25 then
Rotation.Z += MaxTurn
end
elseif PilotSeat.Steer == 0 then
if Rotation.Z > 0 then
Rotation.Z -= MaxTurn
elseif Rotation.Z < 0 then
Rotation.Z += MaxTurn
end
elseif PilotSeat.Steer == 1 then
Rotation.Y -= MaxTurn
if Rotation.Z > -25 then
Rotation.Z -= MaxTurn
end
end
else
Rotation.X = Module.Round(Main.PrimaryPart.Orientation.X)
Rotation.Y = Module.Round(Main.PrimaryPart.Orientation.Y)
Rotation.Z = Module.Round(Main.PrimaryPart.Orientation.Z)
end