Answer the question
In order to leave comments, you need to log in
Why might Input.acceleration not work?
Good day!
I need to get a Vector3 through the accelerometer (Input.acceleration) to rotate a 3D Object.
I tried to get it in this way: Vector3 pos = Input.acceleration;
But no matter how I moved the phone, nothing changed...
I tried to get Vector3 via Input.mousePosition, everything worked out!
! ̶I̶z̶ ̶e̶t̶o̶g̶o̶ ̶s̶l̶e̶d̶u̶e̶t̶ ̶t̶o̶, ̶ ̶ch̶t̶o̶ ̶o̶sh̶i̶b̶k̶a̶ ̶n̶e̶ ̶v̶ ̶k̶o̶d̶e̶ ̶ check
if there is a resolution to Edit -> Project Settings -> Player :But did not find anything: /
check whether all the accelerometer in your phone - there ...
I checked that foreign forums - Found nothing (Maybe I was looking badly).
What could be the problem? (Unity 2018.1.0b12; SDK and JDK present!)
Answer the question
In order to leave comments, you need to log in
My inattention played a cruel joke on me... The code that I did was first sharpened for mousePointer. And in order to normalize the rotation behavior, I found out half of the width and length of the user's screen:
float halfWidth = Screen.width * 0.5f;
float halfHeight = Screen.height * 0.5f;
float x = Mathf.Clamp((pos.x - halfWidth) / halfWidth, -1f, 1f);
float y = Mathf.Clamp((pos.y - halfHeight) / halfHeight, -1f, 1f);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question