Hello, I got a aerodynamics script for my plane. When I start to fly, the plane is very shaking. How do I fix it. (If I move wings, I can handle the shake)
local Part = script.Parent
local Thrust = Instance.new("BodyThrust", Part)
Thrust.Archivable = false
math.randomseed(tick()%1*1e7)
local RayCount = 20
local RayLength = 40
while true do
wait(1/20)
if Part.Velocity.Magnitude > 1 then
local XX, YX, ZX, XY, YY, ZY, XZ, YZ, ZZ = select(4, Part.CFrame:components())
local SurfaceX = Part.Size.Y*Part.Size.Z * (XX*Part.Velocity.X + XY*Part.Velocity.Y + XZ*Part.Velocity.Z)
local SurfaceY = Part.Size.X*Part.Size.Z * (YX*Part.Velocity.X + YY*Part.Velocity.Y + YZ*Part.Velocity.Z)
local SurfaceZ = Part.Size.X*Part.Size.Y * (ZX*Part.Velocity.X + ZY*Part.Velocity.Y + ZZ*Part.Velocity.Z)
local Finds = 0
for N = 1, RayCount do
local R = Ray.new((Part.CFrame * CFrame.new(math.random()*Part.Size.X-Part.Size.X/2, math.random()*Part.Size.Y-Part.Size.Y/2, math.random()*Part.Size.Z-Part.Size.Z/2)).p, Part.Velocity.Unit * RayLength)
local Hit = workspace:FindPartOnRay(R, Part)
if Hit and (Hit.Velocity - Part.Velocity).Magnitude < 1 then
Finds = Finds + 1
end
end
Thrust.Force = Vector3.new(SurfaceX, SurfaceY, SurfaceZ) * -(math.random()/3+0.66) * ((RayCount-Finds)/RayCount)
else
Thrust.Force = Vector3.new(0, 0, 0)
end
end
(the code is not mine, i use it as sample)