oh, I thought it was just sprites. sorry about that. I’m looking through it now
this looks like what I want:
local function walk_path(self, unit)
local pos = go.get_position(unit.id)
local step = table.remove(unit.path, 1)
if step then
local to = pos + step
msg.post(unit.id, "moving", { to = to })
go.animate(unit.id, "position", go.PLAYBACK_ONCE_FORWARD, to, go.EASING_LINEAR, 1 / unit.data.speed, 0, function()
walk_path(self, unit)
end)
end
end
is removing stuff from the table how you interrupt the ongoing animation? I can’t figure out why else that table.remove(unit.path) is there.
edit: this isn’t actually that different from the animation based one I found before, now that I’m figuring it out. two things: my sprite disappears when the animation is over, and as mentioned before idk how to interrupt it so I can click to change the direction while it’s moving
function init(self)
msg.post(".", "acquire_input_focus")
end
function on_input(self, action_id, action)
if action_id == hash("touch") and action.pressed then
local mouse_pos = vmath.vector3(action.x,action.y,0)
local obj_pos = vmath.vector3(go.get_position().x,go.get_position().y,0)
go.animate(".", "position", go.PLAYBACK_ONCE_FORWARD, mouse_pos, go.EASING_LINEAR, 0.5, 0)
print(action.x,action.y)
print(obj_pos.x,obj_pos.y)
end
end
this is what I’ve got now, after pruning out the parts I couldn’t figure out or don’t need to use. can’t figure out why the sprite would go invisible at the end.