Does anybody know, how to set accelerometer values for start a game to set the Y axis center when scene started, depends on angle of holding iphone at the moment?
Something like auto calibration of Y axis each time of start the game… something you put your iphone on the table, so auto calibrate it on that position, but if you hold it in hands, it is in some angle, so when I hit the play game and scene starts, it should be calibrated to center position for the angle you hold iphone at the moment.
Thx
Hi, welcome to the forum!
There isn’t a way to calibrate the accelerometer from a reference point, but you can record the initial position in a variable and measure the orientation relative to that during the game. The easiest way to do this will probably depend on the nature of the game. For example, for a physics-based game, it is probably easiest to set the gravity to the accelerometer direction and rotate the contents of the scene to use this as the downward direction. However, if you are using the forward/backward rotation as an acceleration control, you might be better just recording the initial accelerometer direction in a variable. You could then measure the angle between the reference direction and the current direction with Vector3.Angle or Vector3.Dot.
hey i was wondering if you could go into slightly more of an explanation for this? ive been really trying to figure out how to get basically this some thing going where the player can set a comfortable position before stating the level.
ive been trying to find a good way to find out the current status of my acceleration by using the Input.GetAccelerationEvent, but im actually on android so i cant see the “print” when im testing on my device in order to see the measurements.
Im using the code basicly from this
to move my object around, but i want it to be able to move left/right and up/down, but allow the user to set the position of the device so they dont have to be holding it parallel to the ground.