Hello,
I have this aircraft script that I am currently converting from a plane system to a helicopter system (so don’t mind an F-16 model acting like a helicopter in any GIFs/videos I show)
Going forwards and backwards is going pretty well, however, turning, not so much.
I am trying to get this system to turn its yaw constantly while the player has the Steer either -1 or 1 (it does nothing when the Steer is 0), but also tilt its roll by about 5-10 degrees to the classic helicopter tilting effect. However, when trying this script out, it yields something like this:
So, I have removed the feature, and it works fine, it just doesn’t have the nice tilting…
Below is the code I am using - how would I re-do it in such a way that, when turning, the yaw keeps its angle changing as much as I am steering, but the roll goes to 5-10 degrees and doesn’t go past that?
local seat = script.Parent.VehicleSeat
local engine = script.Parent.Engine
local status = true
local angleChange = script.Parent:GetAttribute("turnSpeed") or .02
local angleType = script.Parent:GetAttribute("turnMode") or "roll"
local speed = 0
local maxSpeed = 50
engine.AlignOrientation.CFrame = engine.CFrame
game["Run Service"].Heartbeat:Connect(function()
task.wait(.1)
if status == true then
if seat.Throttle == 1 then
if speed < maxSpeed then
speed = speed + 1
end
engine.LinearVelocity.VectorVelocity = (engine.CFrame.lookVector)*speed
elseif seat.Throttle == -1 then
if speed > -maxSpeed then
speed = speed - 1
end
engine.LinearVelocity.VectorVelocity = (engine.CFrame.lookVector)*speed
elseif seat.Throttle == 0 then
if speed ~= 0 then
if speed > 0 then
speed = speed - 1
else
speed = speed + 1
end
end
engine.LinearVelocity.VectorVelocity = (engine.CFrame.lookVector)*speed
end
if seat.Steer == 1 then
engine.AlignOrientation.CFrame = (engine.AlignOrientation.CFrame) * CFrame.fromEulerAnglesXYZ(0, -angleChange, 0)
--- turn right
elseif seat.Steer == -1 then
engine.AlignOrientation.CFrame = (engine.AlignOrientation.CFrame) * CFrame.fromEulerAnglesXYZ(0, angleChange, 0)
--- turn left
end
end
end)