I’ve made a few topics on this, but I have not gotten my AlignPosition issues settled.
Basically, I created a plane system using the old BodyMovers, however, they would cause issues when I would change the NetworkOwnerShip of them, or at least I think that is the case (since they are depreciated and have been for a long time), as seen in this post.
I got LinearVelocity to work, as it was just a simple conversion from BodyVelocity to LinearVelocity with very little change to my code. However, when switching over to AlignOrientation from BodyGyro, I have failed to get the results I wanted. All that will happen, is the plane will start up, and then start to rotate violently before the impact detection system built into the planes blows it up.
You can see how horrific it is here. No errors show up in output, making this even more frustrating.
I am not sure what I am doing wrong. Here is the LocalScript code for handling the plane movement, using LinearVelocity and AlignOrientation:
local player = game.Players.LocalPlayer
local char = player.Character or player.CharacterAdded:Wait()
local Humanoid = char:WaitForChild("Humanoid")
local val = script:WaitForChild("plane")
local connection = val.Value
local USINS=game:getService("UserInputService")
local engine = connection:WaitForChild("Engine")
local gyro = engine:WaitForChild("AlignOrientation")
local velo = engine:WaitForChild("LinearVelocity")
local clickMove = false
local function GetBankAngle(M) --This function calculates the Bank Angle
local VSX,X = M.ViewSizeX,M.X
local Ratio = (((VSX/2) - X)/(VSX/2))
Ratio = (Ratio < -1 and -1 or Ratio > 1 and 1 or Ratio)
return math.rad(Ratio * 80)
end
local function SetAlignOrientationCFrame(alignOrientation, cframe)
alignOrientation.PrimaryAxis = cframe.RightVector
alignOrientation.SecondaryAxis = cframe.UpVector
end
if connection ~= nil then
game["Run Service"].RenderStepped:Connect(function(step)
if not USINS:GetFocusedTextBox() then
Mouse.TargetFilter = game.Workspace
local BankAngle = GetBankAngle(Mouse)
if clickMove then
SetAlignOrientationCFrame(gyro,((LastHit or Mouse.Hit)*CFrame.Angles(0,0,BankAngle)))
else
SetAlignOrientationCFrame(gyro,(Mouse.Hit*CFrame.Angles(0,0,BankAngle)))
end
velo.VectorVelocity = (engine.CFrame.lookVector)*values.currSpeed.Value
end
end)
end
When compared to the old script, it is almost the same:
local player = game.Players.LocalPlayer
local char = player.Character or player.CharacterAdded:Wait()
local Humanoid = char:WaitForChild("Humanoid")
local val = script:WaitForChild("plane")
local connection = val.Value
local USINS=game:getService("UserInputService")
local engine = connection:WaitForChild("Engine")
local gyro = engine:WaitForChild("BodyGyro")
local velo = engine:WaitForChild("BodyVelocity")
local clickMove = false
function GetBankAngle(M) --This function calculates the Bank Angle
local VSX,X = M.ViewSizeX,M.X
local Ratio = (((VSX/2) - X)/(VSX/2))
Ratio = (Ratio < -1 and -1 or Ratio > 1 and 1 or Ratio)
return math.rad(Ratio * 80)
end
if connection ~= nil then
game["Run Service"].RenderStepped:Connect(function(step)
if velo.MaxForce == Vector3.new(math.huge,math.huge,math.huge) and not USINS:GetFocusedTextBox() then
Mouse.TargetFilter = game.Workspace
local BankAngle = GetBankAngle(Mouse)
--gyro.maxTorque = Vector3.new(math.huge,math.huge,math.huge)
--velo.maxForce = Vector3.new(math.huge,math.huge,math.huge)
if clickMove then
gyro.cframe = ((LastHit or Mouse.Hit)*CFrame.Angles(0,0,BankAngle))
else
gyro.cframe = (Mouse.Hit*CFrame.Angles(0,0,BankAngle))
end
velo.velocity = (engine.CFrame.lookVector)*values.currSpeed.Value
end
end)
end
I’m sort of at my wit’s end for this, and this plane system is super important for my current and future games, so I would appreciate some help with this.