Attempt at fixing orientation for move to.

This commit is contained in:
Harrison Deng 2021-05-09 14:15:20 -05:00
parent 096de7f8e3
commit 9e9ea5dd2f

View File

@ -410,8 +410,16 @@ local function moveTo(dest, relative)
sendLog(FAILED, "Unable to orient for X axis.") sendLog(FAILED, "Unable to orient for X axis.")
return return
end end
if relative then
forward = relHeading
right = relRightAxis
else
forward = heading
right = rightAxis
end
xblocked = not attemptMoveForward() xblocked = not attemptMoveForward()
end end
if position.y ~= dest.y then if position.y ~= dest.y then
if dest.y - pos.y > 0 then if dest.y - pos.y > 0 then
yBlocked = not attemptMoveUp() yBlocked = not attemptMoveUp()
@ -419,6 +427,7 @@ local function moveTo(dest, relative)
yBlocked = not attemptMoveDown() yBlocked = not attemptMoveDown()
end end
end end
if pos.z ~= dest.z then if pos.z ~= dest.z then
if not orient(vector.new(0, 0, dest.z - pos.z):normalize(), forward, right) then if not orient(vector.new(0, 0, dest.z - pos.z):normalize(), forward, right) then
sendLog(FAILED, "Unable to orient for Z axis.") sendLog(FAILED, "Unable to orient for Z axis.")
@ -426,6 +435,13 @@ local function moveTo(dest, relative)
end end
zBlocked = not attemptMoveForward() zBlocked = not attemptMoveForward()
end end
if relative then
forward = relHeading
right = relRightAxis
else
forward = heading
right = rightAxis
end
end end
end end