Using accelerometer to operate a turret


I’m looking to get into mobile development, or at least try it out. For this I’m wanting to create a simple “tower defense” game where you operate a “turret” and shoot incoming hostiles. However since my phone doesn’t have a gyroscope I’m unable to create a more natural feeling aiming system where you move the phone around you in a VR like motion to aim…
I do however have an accelerometer (which I assume most mobile devices have now?) which allows me to aim the tutret, but doesn’t feel very natural as you’re just tilting the screen to aim… See the place below on mobile to see what I mean.

Other then possibly increasing the rotation speed, what else would I need to do to make it feel more natural?

Also as a note, looking horizontally might be inverted for IOS users. Don’t know if this true or not as I’m android.


Had the time today to do it, so I added options for inverted controls and sensitivity sliders. However, still feels weird.


I looked into doing this a little while ago and now you make me want to do it again. I can work on a gyroscope equivalent and share my code with you if you wish. You could toggle between the two depending on if there is a gyroscope as the gyroscope one would probably be more accurate. The issue I found is you can’t assume the orientation the user is when they start, so you have to adapt a lot of your code depending on their initial orientation.

Edit: just tried out your demo place. The issue with it is you assume that if they’re moving their phone up they are rotating it above them. Because of this I could have my phone facing the same way and move it straight up and your turret will rotate. You should also take the z-axis acceleration into account to determine if they’re moving the phone straight up and down or rotating it. Also your movement doesn’t seem snappy enough, seems to start late and end late. It also just seems to move a little too slowly. Unfortunately I don’t think the acceleration is too reliable which sucks because a lot of older phones that Roblox supports do not have gyroscopes