How do I get my plane system to be more stable/work right?

I am attempting to make a plane system in which you control the operation of it with the WASD keys. W/S makes it turn up or down, and A/D makes it turn right/left.

I have constructed this simple rig to get started, before I move onto the more advanced plane models I have.

I have made the system using BodyGyro (I know it is recommended to switch to AlignOrientation but I have no had the best of luck with it, and I am far more used to BodyGyro) and LinearVelocity. The system is extremely unstable. Before, it would turn, but the turns would be horrifically overstated, and now it doesn’t do anything when I used WASD keys, as seen below.

You can see it struggles to respond to my controls.

Here is the code for it:

local seat = script.Parent.VehicleSeat
local engine = script.Parent.Part
local status = false

game["Run Service"].Heartbeat:Connect(function()
	task.wait(.1)
	if status == true then
		if seat.Throttle == 1 then
			engine.BodyGyro.CFrame = engine.BodyGyro.CFrame * CFrame.fromEulerAnglesXYZ(2, 0, 0)
		elseif seat.Throttle == -1 then
			--- rotate down
			engine.BodyGyro.CFrame = engine.BodyGyro.CFrame * CFrame.fromEulerAnglesXYZ(-2, 0, 0)
		else
			engine.BodyGyro.CFrame = engine.BodyGyro.CFrame * CFrame.fromEulerAnglesXYZ(0, 0, 0)
		end
		if seat.Steer == 1 then
			engine.BodyGyro.CFrame = engine.BodyGyro.CFrame * CFrame.fromEulerAnglesXYZ(0, 0, 2)
			--- turn right
		elseif seat.Steer == -1 then
			engine.BodyGyro.CFrame = engine.BodyGyro.CFrame * CFrame.fromEulerAnglesXYZ(0, 0, 2)
			--- turn left
		else
			engine.BodyGyro.CFrame = engine.BodyGyro.CFrame * CFrame.fromEulerAnglesXYZ(0, 0, 0)
		end
	end
	if engine.LinearVelocity.MaxForce == math.huge then
		engine.LinearVelocity.VectorVelocity = (engine.CFrame.lookVector)*100
	end
end)

--- below is for toggling the engine on and off, not very important
engine.ClickDetector.MouseClick:Connect(function()
	if seat.Occupant ~= nil then
		if status == false then
			status = true
			engine.LinearVelocity.MaxForce = math.huge
			engine.BodyGyro.MaxTorque = Vector3.new(math.huge,math.huge,math.huge)
		else
			status = false
			engine.LinearVelocity.MaxForce = 0
			engine.BodyGyro.MaxTorque = Vector3.new()
		end
	end
end)
1 Like

The instabilities are most likely either to your PhysicsSteppingMethod in workspace being Adaptive (it’s more unstable with legacy body movers) or because you’re mixing constraint based movers with body movers.

Also with AlignOrientation to get the result that you want you can use AlignOrientation in OneConstraint mode and update the CFrame of it.

I’ve used BodyGyro with LinearVelocity before, no issue.

Could you walk me in the direction on how I would use AlignOrientation/convert to it based on the code I have posted?

  1. Add a AlignOrientation where the BodyGyro currently is
  2. Set the Mode to OneAttachment (property)
  3. Set the Attachment0 to the same Attachment you’re using for the LinearVelocity
  4. In your script, replace all references to the BodyGyro to the AlignOrientation object. You can do this using Find and Replace.

It should work, but if there’s still issues I can help.
Also I reconmend removing the part thar changes the MaxTorque to infinite, it will increase stabillity if you set it to a lower number.

Ok, so I changed things up, and this is how it ended up behaving:

It immediately sends me into a nosedive. I replaced all references in my script from “BodyGyro” to “AlignOrientation” and made the MaxTorque 3000

It definitely tries to respond to the steer and throttle, but it just doesn’t do it nicely at all.

Here’s a video showing that the AlignOrientation is responding to the throttle and steer inputs, but the effects on the overall plane are negligible

OK, looks like I got it work. It seems like you DO have to make it so that the MaxTorque is absurdly high for it to work.

However, one issue I ran into is, the plane’s orientation only changes when there is nothing underneath it., like when it flies off of the baseplate. This is an issue, since when this is implemented into my game, planes will spawn on a runway, and won’t be able to “take off” if the AlignOrientation angle won’t have a visible change until there is nothing but the void of ROBLOX underneathe the plane…

Maybe decrease the friction of the parts on the ground using CustomPhysicalProperties?