i’ve been trying to figure out how i can hover a simple part(thruster) for something like a hover car, this is the math i’ve been using but sadly it doesn’t work.
function gethoverinformation()
local ray = Ray.new(script.Parent.Position+Vector3.new(0,-10,0),((script.Parent.Position+Vector3.new(0,-10,0))-script.Parent.Position).unit*10)
return workspace:FindPartOnRay(ray,script.Parent)
end
local hvpower = script.Parent:GetMass()*196.2 -- our mass
local damping = 6 --damnping
local hoverheight = 5 --how hich we want to hover
local oldheight = 0 -- height we were on just a secodn ago
while true do
local Part,Pos = gethoverinformation() -- gets the part and hitposition below
local height = (Pos - script.Parent.Position).magnitude -- calculates the height between those 2 points
local deltaheight = (height-oldheight) -- how the height has changed
local power = (hoverheight-height-(deltaheight)*damping)*hvpower -- the math i am using
script.Parent.BodyThrust.Force = Vector3.new(0,power,0) -- trying to hover
coroutine.yield() -- once thats executed lets change the old height and start all overagain.
oldheight = height
end
this is the formation i’ve been using. each part has the script and a body trust
anyone could figure out whats wrong with my math?