# Is there any difference between the reading of sensors in Unity5 and Android/Java?

I'm an Android/Java developer, and I'm new to unity5. I have a program written in Android/Java that uses the readings of three sensors( Accelerometer, Magnetometer and LinearAccelertion ).

I'm now developing my first game in unity5, and I want to use the algorithm that uses the three sensors readings in my game.

In Android/Java, sensors readings are normally row data, which means that I must make some calculations on these data to be able to use them in my program.

Do I also have to make these calculations in unity5? Are the reading of sensors in Android/Java and unity5 the same or different?

If they are different, how can I use them?

Disclaimer: so far my experience with motion control in Unity has been with devices not supported by the Input class, so I've always rolled my own sensor fusion as you describe. The description below is based on the docs - I'd welcome corrections or further details from anyone with hands-on experience.

Unity provides a few ways to access the motion of the device without needing to do the fusion yourself:

• Input.gyro.attitude (Quaternion) gives the orientation of the device in space. It's unclear to me from the docs whether this includes magnetic heading information when available, or if it might be prone to yaw drift.

• Input.gyro.userAcceleration (Vector3) gives the local linear acceleration of the device, with the estimated contribution due to gravity subtracted out.

• Input.gyro.rotationRateUnbiased (Vector3) gives the local gyroscope rotation rate readings in radians per second, after compensating for biases.

• Input.compass.magneticHeading (float) gives the heading in degrees from the top of the screen (in its current orientation) to magnetic north.

• Input.compass.trueHeading (float) gives the heading in degrees from the top of the screen (in its current orientation) to geographic north, once you've enabled location updates by calling Input.location.Start()

Note that to use these methods you'll need to enable the gyroscope or compass respectively.

I don't know how these compare in terms of performance or accuracy compared to rolling your own sensor fusion, but like most of Unity I'd expect they'd at least provide a solid starting point for prototyping.