Playing sprite animation also restarts animation (SOLVED)

the sprite animates correctly, but i want it to continue playing from where it started instead of starting from the beginning every time:


i’m pretty sure this has to do with my input handler:

function on_input(self, action_id, action)
	if action_id == hash("D") then
		self.right = action.released and 0 or 1
		update_move_vector(self)
	elseif action_id == hash("A") then
		self.left = action.released and 0 or 1
		update_move_vector(self)
	elseif action_id == hash("W") then
		self.up = action.released and 0 or 1
		update_move_vector(self)
	elseif action_id == hash("S") then
		self.down = action.released and 0 or 1
		update_move_vector(self)
	elseif action_id == hash("shift") then
		self.shift = not action.released
		update_move_vector(self)
	end
end

is there an easy way to make the sprite animate like i wanted?

1 Like

You mean mainly when it is “idle”? You should store somewhere properly the “cursor” position of the animation and start playing sprite animation with an offset, here’s API reference:

Some examples using cursor to better understand it:

2 Likes