Accelerometer input on iOS not working

Hi everyone, my mobile app works with accelerometer input on Android but not on iOS. I have been pulling my hair out on this.

  1. in game.project Use Accelerometer is checked.
  2. 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

Well, it could be that we’ve broken accelerometer support in some release and not noticed it until now. I suggest that you create a bug report on GitHub.

Ok, done. Attached a minimal project that reproduces the behavior.

2 Likes