I'm making a game where by tilting my smartphone I can rotate an object in the z-axis. I made sure that the rotation is correct at different angles of the smartphone, but the problem is that if you pick up a smartphone and start turning around its axis, the angle of the object also changes.
Is it possible to read only tilts along the z-axis and not count the movement of the smartphone along the y-axis (around its own axis)?
P.S. Similar behavior of the gyroscope in games like Traffic Racer and Traffic Rider, only when the smartphone is rotated, the object moves to the sides, and I need to rotate it.
It depends a bit on how you define
Zaxis for a phone but you could try and use something like e.g.this will only rotate the transform around the global Z axis.
Or if you need it in local space you can get the angle relative to the World right vector and do e.g.