I am currently working on a realistic plane system, but I’m already running into issues. As you can see from this gif, the plane is not going in the direction in which it is facing.
I am not sure why it is rotating, but even then, the plane does not go in the direction that it is facing. This is my code:
local function SetLeftEnginesForce(Force)
for _,Engine in pairs(LeftEngines:GetChildren()) do
if Engine then
if Engine:IsA('BasePart') then
local EngineThrust = Engine:FindFirstChild('EngineThrust')
if EngineThrust then
EngineThrust.Force = Engine.CFrame * Engine.CFrame.lookVector * Force
end
end
end
end
end
local function SetRighttEnginesForce(Force)
for _,Engine in pairs(RightEngines:GetChildren()) do
if Engine then
if Engine:IsA('BasePart') then
local EngineThrust = Engine:FindFirstChild('EngineThrust')
if EngineThrust then
EngineThrust.Force = Engine.CFrame * Engine.CFrame.lookVector * Force
end
end
end
end
end
Increase the Force variable; the length of the vector determines the Force applied. Your plane looks heavy, a regular 2x1x4 brick starts to move at around 300-400.
Oh yeah, my bad, thanks! Another thing that I am having an issue with is with BodyGyros. I am trying to make it rotate by 45 degrees relative to the parts position and orientation.
You’ll want to alter the .CFrame property of the BodyGyro for that. For a 45 degree rotation on the Y-axis (I think that’s what the gif is showing?) you’d set it to;
Actually let me be more specific.
If a player can sit in the plane to control it, you can use a VehicleSeat and BodyAngularVelocity to rotate the plane. The Vehicle seat has a property that detects which way the player wants to go. According to the Wiki, 1 = right, 0 = straight, -1 = left. You can do something like this for the rotation
local speed = 100 BodyAngularVelocity.AngularVelocity = Vector3.new(0, (speed * -(seat.Steer)),0)
Just make sure the Torque and P property are adjusted correctly for the size of the plane.
You can also use a BodyGyro for dampening but just set the CFrame to the CFrame of the primaryPart of the plane.
That wouldn’t work because BodyAngularVelocity doesn’t have a goal so it would just keep going in that direction. Usually this would work with things like the Crazyman32 plane kit, but mine is going to control differently.
EDIT: I have made the code for setting the CFrame of the Gyro to CFrame.Angles(Elevator.CFrame.upVector * 45)
But I get the error: bad argument #3 to 'Angles' (number expected, got no value)
This is because CFrame.Angles only takes numbers but here you are giving it a vector.
Try doing CFrame.Angles(lookVector.X, lookVector.Y, lookVector.Z)
You should know that the fact you found a different way is not the solution to the topic. Threads in development support are meant to be an archive for anyone in the future to find the answer to their question.
If @Eventive’s method works, then that is the solution to this thread’s question.
What way are you using then? I’m not sure what CM32’s Plane Kit consists of but you could use BodyVelocity and BodyAngularVelocity (using the method I originally replied with).
Using the Velocity you can set the Velocity using the VehicleSeat’s Throttle property and times it by a speed, the speed can be a variable that changes if you want it to accelerate over time.
This would make the plane controllable and you can add in some special code to act like a normal plane.
If you’ve already settled on a way, then disregard this, it’s just an option
EDIT:
Using a VehicleSeat would only partially work for airplanes. You would have to manipulate it a bit to add up/down controls. Possibly using ContextActionService.