So many good ideas! I’m going to give it a shot right now and update you.
I’ve made a basic interpretation of it, but it doesn’t get level with the ground:
https://gyazo.com/f41ef5a3a9052bed4e4d32a9500ec1ae
local RS = game:GetService("RunService")
local Weight = script.Parent.Mass:GetMass() * workspace.Gravity
local Load = script.Parent.Load
local Thrusters = script.Parent.Thrusters:GetChildren()
local TargetDistance = 4
local MaxDist = TargetDistance * 3
function GetDist(v)
local Origin = v.Position
local Rayn = Ray.new(Origin, v.CFrame.UpVector * (-MaxDist -1))
local hit, pos = workspace:FindPartOnRayWithIgnoreList(Rayn, script.Parent:GetDescendants())
return pos, (Origin - pos).Magnitude
end
RS.Stepped:Connect(function()
for i, v in pairs(Thrusters) do
local pos, Distance = GetDist(v)
if Distance <= MaxDist then
v.BodyPosition.MaxForce = Vector3.new(0,Weight, 0)
v.BodyPosition.Position = Vector3.new(0,pos.Y + TargetDistance + v.Size.Y/2,0)
else
v.BodyPosition.MaxForce = Vector3.new()
end
end
end)
(I will add damping later, i just need this to work atm)
Oh, I didn’t know that you wanted it always level (since a real life car would not be level). In that case, you can just use the largest/smallest distance, take the average of the distances, or do something else along those lines.
Not always level, it's just you can see in the gif, the car is tilted off into one direction and it stays like that
I couldn’t really tell. It looked good to me, but I guess the video was short.