Unit circles idly after SetUnitMoveGoal completes
Posted: 16 Feb 2017, 14:38
Heya, I've a simple custom command set up that issues raw move orders, mostly copied from ZK's https://github.com/ZeroK-RTS/Zero-K/blo ... w_move.lua
The issuing looks like so:
And it works. But once the order finishes, the unit starts circling, instead of coming to a full stop.
This is the original ZK code + my modification for the command callins:
UnitCmdDone gets called as appropriate, but the orders issued within it seem to not do much anything.
Ideas for how to stop the unit after SetUnitMoveGoal finishes?
The issuing looks like so:
Code: Select all
Spring.SetUnitMoveGoal(unitID, cmdParams[1],cmdParams[2],cmdParams[3],64,nil,true)
This is the original ZK code + my modification for the command callins:
Code: Select all
function gadget:UnitCmdDone(unitID, unitDefID, unitTeam, cmdID, cmdTag)
if (cmdID == CMD_RAW_MOVE) then
Spring.Echo("Unit cmd done")
Spring.ClearUnitGoal(unitID)
spGiveOrderToUnit(unitID, CMD.STOP, {}, {})
else
return false
end
end
function gadget:CommandFallback(unitID, unitDefID, teamID, cmdID, cmdParams, cmdOptions) -- Only calls for custom commands
if (cmdID ~= CMD_RAW_MOVE) then
return false
end
local x, y, z = spGetUnitPosition(unitID)
local distSqr = GetDistSqr({x, y, z}, cmdParams)
if (distSqr > (64)) then
return true, false -- command was used but don't remove it(unit have not reach destination yet)
else
--spGiveOrderToUnit(unitID, CMD.STOP, {}, {})
Spring.Echo("Removing cmd..")
return true, true -- command was used, remove it (unit reached destination)
end
end
Ideas for how to stop the unit after SetUnitMoveGoal finishes?