Hello. I have a simple question.
I’m creating 2D shmup, I want to provide 8-directional input on both digital pads and analog stick.
But I can’t find how to get diagonal input from analog stick.
I tried below input settings and took the gamepad input logs.
function on_input(self, action_id, action)
state.on_input(action_id, action, TSys.state)
if action_id == hash("s_up") then
if action.pressed then
print("s_up", action.value) -- a value between 0.0 an -1.0
elseif action.released then
print("s_up released")
end
elseif action_id == hash("s_down") then
if action.pressed then
print("s_down", action.value) -- a value between 0.0 an -1.0
elseif action.released then
print("s_down released")
end
elseif action_id == hash("s_left") then
if action.pressed then
print("s_left", action.value) -- a value between 0.0 an -1.0
elseif action.released then
print("s_left released")
end
elseif action_id == hash("s_right") then
if action.pressed then
print("s_right", action.value) -- a value between 0.0 an -1.0
elseif action.released then
print("s_right released")
end
end
end
But, It seems that previous direction input is released before next direction input is pressed, so it seems that I can’t detect diagonal input.
How can I get diagonal input from analog stick?
Thanks.