Hey there!
I was trying Hovercrafts today and I used raycasts to check altitude.
Here’s my code.
while wait(0.6) do
local raycastParams = RaycastParams.new()
raycastParams.FilterType = Enum.RaycastFilterType.Blacklist
raycastParams.FilterDescendantsInstances = {script.Parent.Parent.Parent}
local raycastResult = workspace:Raycast(script.Parent.Position, Vector3.new(0,-1,0).Unit * 100, raycastParams)
if raycastResult then
local distance = (script.Parent.Position - raycastResult.Instance.Position).Magnitude
print(raycastResult.Instance:GetFullName())
if distance < 22 then
script.Parent.BodyForce.Force = Vector3.new(0,5550,0)
print("too close")
else
script.Parent.BodyForce.Force = Vector3.new(0,0,0)
end
print(distance)
end
end
And something happens with it, which is expected, ngl
https://gyazo.com/3c1e7638e146f9c9f3ac2957650d0361
So what happens is, when the bike reaches at the limit (22), then it’s force goes to zero, which makes it fall suddenly. Is there anything I could do to almost fix it on the limit, but at the same time make give it smooth movement?