Hello!
I’m trying set object rotation to match phone. My current code are just changing rotation without any phone movement. Thats little weird. Is there any way to do that?
I didn’t test this but I think Input.acceleration gives a value between -1.0f and 1.0f. You can use transform.eulerAngels to specify a rotation in degrees.
Input.acceleration is nothing like what you’re using it for. If you’re holding the phone still, acceleration is a vector pointing downward (towards gravity) relative to the phone. It’s a direction vector and not a rotation. If the user is facing the phone directly forward, Input.acceleration will be the same as Vector3.down (that is, (0, -1, 0) ).
The closest thing to what you’re trying to use it for here is Input.gyro.attitude. If you set transform.rotation to that it’ll be kind of like what you want to do. It’s not perfect, and IIRC it’ll be awkward depending on the starting rotation of the phone and so on, but it’ll be close-ish, maybe close enough for you to use for your purposes.