Hello everyone, I have an issue where during the jump animation, if i press the right button, the walking animation is playing in the air. How to solve this? I want the animation to play only the jump animation regardless if i press right or left button. Most of the code I have been using right now is based on the example given. Thank you
function on_input(self, action_id, action)
if action.pressed then
-- key pressed
-- set movement direction and animation according to key
if action_id == hash("left") then
self.direction.x = -1
play_animation(self, hash("move-left"))
elseif action_id == hash("right") then
self.direction.x = 1
play_animation(self, hash("move-right"))
elseif action_id == hash("jump") then
jump(self)
play_animation(self, hash("move-jump-right"))
elseif action_id == hash("jump") then
jump(self)
play_animation(self, hash("move-jump-left"))
end
elseif action.released then
-- key released
-- clear movement direction
-- set idle animation if no movement direction
if action_id == hash("left") then
self.direction.x = 0
if vmath.length(self.direction) == 0 then play_animation(self, hash("idle-left")) end
elseif action_id == hash("right") then
self.direction.x = 0
if vmath.length(self.direction) == 0 then play_animation(self, hash("idle-right")) end
elseif action_id == hash("jump") then
abort_jump(self)
--play_animation(self, hash("fall-right"))
end
end
end