I’m trying to make a hoverboard using align position and align orientation my current plan/idea is to have a part that will rotate based on input which will then control the orientation (with align orientation) of the hoverboard and then a ray shooting down from the hoverboard and then lowering it based on the distance (with align position)
It very clearly doesn’t work, but it did somewhat do what I was trying to do so perhaps I’m on the right track?
(very rough code)
HoverboardComponent.Started:Connect(function(component)
local instance = component.Instance
local params = RaycastParams.new()
params.FilterDescendantsInstances = {}
params.FilterType = Enum.RaycastFilterType.Blacklist
params.IgnoreWater = true
local ap = instance.AlignPosition
RunService.Stepped:Connect(function(dt)
local origin = instance.Position
local direction = -(instance.CFrame.UpVector) * 20
local result = workspace:Raycast(origin, direction, params)
if result then
VisualizeRay(origin,result,result.Position)
local distance = (instance.Position - result.Position).Magnitude
ap.Position = result.Position -- trying to lower the part to the surface
end
end)
end)