Hi everyone, my mobile app works with accelerometer input on Android but not on iOS. I have been pulling my hair out on this.
- in game.project Use Accelerometer is checked.
- there are three input bindings, left, right, space, and mouse trigger - Button1 mouse
This is the code for input in the player.script. Movement is handled in update. It works on PC, mac and Android. I hope I am missing something obvious . . .
function on_input(self, action_id, action)
if not action_id then
if action.acc_x then
self.direction.x = action.acc_x * 4
end
end
if action_id == hash("right") then
self.direction.x = DIRECTION_RIGHT
elseif action_id == hash("left") then
self.direction.x = DIRECTION_LEFT
end
move(self)
end
function move(self)
self.velocity.x = BASE_VELOCITY * self.direction.x
end