I’m trying to implement a feature that the character is smoothly pushed backwards during a collision (i.e. the typical recoil after a blow), but so far nothing is working…
function update(self, dt)
--Monster_move
local pos = go.get_position()
pos.x = pos.x - monster_stats.speed
go.set_position(pos)
function kickback()
for i = 1, 10 do
pos.x = pos.x + 1
go.set_position(pos)
end
end
end
But the character just teleports, there is no smooth movement like when pos.x = pos.x + 1 in the body of the update function.
I call the kickback function itself when I receive a damage message.