So my problem is that the plane would fly horizontally. I have checked every part to see if they match every side but couldn’t find anything. I have also tried to disable the propeller but it also didn’t work.
Actually it’s rolling to the right, not flying horizontally.
Here are some suggestions for trying to troubleshoot and test after each one to see if it makes any difference:
Try removing the propellers entirely.
Keep the propellers on, but weld them to the airframe so they don’t turn at all.
Try rotating one propeller clockwise and the other one counter-clockwise.
It may also be a balance issue. Planes IRL and on Roblox have to be balanced front to back as well as side to side. A plane that has its center of mass too far forward of its center of lift is hard to control. One that has its center of mass too far aft of its center of lift will become very unstable and hard to control.
On another note, real planes use the ailerons on the wing for roll control, not for pitching up and down. They use a control surface called an elevator at the back to push the tail down to increase the angle of the wing compared to the air the plane is flying through and lift up, or to push the tail upwards to decrease the angle of the wing and point the nose down.
This is basically what I was telling you about in your first plane post.
I have tried all this but it hasn’t fixed my issue. I have checked my plane to see if they are balanced and I don’t see anything causing this and I also tried to counter-clockwise and clockwise but they didn’t help. I also have center of mass enabled on the VectorForce too.
I just remade the plane but it still had the same problem. I think the problem is in the script.
Module:
local module = {}
local module = {}
local RunService = game:GetService("RunService")
local UserInputService = game:GetService("UserInputService")
local player = game.Players.LocalPlayer
local model = script.Parent.Parent
local Parts = model:WaitForChild("Parts")
local VehicleSeat = Parts:WaitForChild("VehicleSeat")
local Constraints = model:WaitForChild("Constraints")
local activated = false
local flySpeed = 1000000
local turnSpeed = 1
local steer = 0
local ascend = 0
local throttle = 0
local steerTargetAngle = 30
local propellerSpeed = 100
local accelerateConnection
local decelerateConnection
function module.DisconnectConnection(connection)
if connection then
connection:Disconnect()
connection = nil
end
end
function module.Propeller(bool)
for i,v in ipairs(Constraints:GetChildren()) do
if v:IsA("HingeConstraint") then
if v.Name == "LeftPropellerHinge" then
if bool then
v.AngularVelocity = propellerSpeed
else
v.AngularVelocity = 0
end
elseif v.Name == "RightPropellerHinge" then
if bool then
v.AngularVelocity = -propellerSpeed
else
v.AngularVelocity = 0
end
end
end
end
end
function module.FlyForward()
for i,v in ipairs(Constraints:GetChildren()) do
if v:IsA("VectorForce") and string.find(v.Name, "Fly") then
local part = v.Attachment0.Parent
if part then
local velocity = (part.CFrame.LookVector * throttle).Magnitude
v.Force = part.CFrame.LookVector * velocity
end
end
end
end
function module.Steer()
for i,v in ipairs(Constraints:GetChildren()) do
if v:IsA("HingeConstraint") then
if v.Name == "RightWingFlapHinge" then
v.TargetAngle = -steerTargetAngle * (steer - ascend)
elseif v.Name == "LeftWingFlapHinge" then
v.TargetAngle = steerTargetAngle * (steer + ascend)
end
end
end
end
function module.Accelerate()
if throttle < flySpeed then
throttle += 5000
else
if throttle ~= flySpeed then
throttle = flySpeed
module.DisconnectConnection(accelerateConnection)
end
end
end
function module.Decelerate()
if throttle > 0 then
throttle -= 5000
else
if throttle ~= 0 then
throttle = 0
module.DisconnectConnection(decelerateConnection)
end
end
end
function module.Fly()
if model.PrimaryPart then
steer = VehicleSeat.Steer
ascend = VehicleSeat.Throttle
module.FlyForward()
module.Steer()
end
end
function module.Stop()
activated = false
module.DisconnectConnection(accelerateConnection)
module.Propeller(false)
coroutine.wrap(function()
decelerateConnection = RunService.Heartbeat:Connect(function()
module.Decelerate()
end)
end)()
end
function module.Run()
activated = true
module.DisconnectConnection(decelerateConnection)
module.Propeller(true)
coroutine.wrap(function()
accelerateConnection = RunService.Heartbeat:Connect(function()
module.Accelerate()
end)
end)()
end
coroutine.wrap(function()
RunService.Heartbeat:Connect(function()
module.Fly()
end)
end)()
return module
I was playing around with it last night. It’s not the script. It got late and I was still experimenting with it.
I also see that you didn’t click on the link about how planes fly and are controlled. I added an elevator in the horizontal stabilizer (the horizontal tail control surface) and it works much better.
Why do you have soooo many Parts in it? All the long line of Parts of the fuselage (the plane body) cab be made from 1 Part each.
Your weld script also welds all touching Parts, making you have about 8 times the number of welds required. Most weld scripts just use 1 weld per Part. This is also made worse by having 3 times as many Parts as required.
4 .Why 2 separate thrust VectorForces, 1 in each engine? You could just put 1 in the center of the aircraft. (I just put both in the VehicleSeat but you could make 1 do the same job.
I think the issue is the aerodynamics of the fuselage having the rear section angled up. I quit working on it at about 2:00 am. I’ll try again tonight.
Wait no, I think there is actually something wrong with the script. I created a test plane and for some reason, it also turns to the right.
Video:
Code:
local RunService = game:GetService("RunService")
local model = script.Parent
local Constraints = model:WaitForChild("Constraints")
local speed = 20000
local function Fly()
for i,v in ipairs(Constraints:GetChildren()) do
if v:IsA("VectorForce") then
local part = v.Attachment0.Parent
if part then
local velocity = part.CFrame.LookVector * speed
v.Force = velocity
end
end
end
end
RunService.Heartbeat:Connect(function()
Fly()
end)
The turning issue is probably due to your 2 vectorforces. When I made them centered the turning issue was fixed, it was just the up and down issue I was having.
So there is no way to fix this? I have also tried this but hasn’t worked:
local oldVelocity
local function Fly()
for i,v in ipairs(Constraints:GetChildren()) do
if v:IsA("VectorForce") then
local part = v.Attachment0.Parent
if part then
if not oldVelocity then
local velocity = part.CFrame.LookVector * speed
v.Force = velocity
else
v.Force = oldVelocity
end
end
end
end
oldVelocity = nil
end