Input.Deviceorientation:
(Example: If (input.Deviceorientation=
Deviceorientation.Facedown))
- Unknown: The device direction cannot be determined.
- Portrait: The device is in portrait mode, and the device is upright and the Home button is at the bottom.
- Portraitupsidedown: The device is in portrait mode, but it is reversed. The device is upright and the Home button is on the top.
- Landscapeleft: The device is in Landscape mode, and the device is upright and the Home button is on the right.
- Landscaperight: The device is in Landscape mode, and the device is upright and the Home button is on the left.
- Faceup: The device is kept parallel to the ground, and the screen area is up.
- Facedown: The device is kept in parallel with the ground, and the screen is facing down.
Acceleration Sensor
Input.Acceleration: Hold the device vertically (the home button is at the bottom), the X axis points to the right, the Y axis points to the up, And the Z axis points to the forward.
The accelerometer value may be affected by bumps. When the application is low, the filter can make it smooth and free from interference.
// The accelerator Refresh Interval float accelerometerupdateinterval = 1.0f/60366f; // a larger value means that the filtered value will combine the slower the current input sampling float lowpasskernelwidthinseconds = 1.0f;
// Filter range
Private float lowpassfilterfactor = accelerometerupdateinterval/lowpasskernelwidthinseconds; private vector3 lowpassvalue = vector3.zero; void start () {lowpassvalue = input. acceleration;} // filtering method (call this method to obtain the amount of acceleration) vector3 lowpassfilteraccelerometer () {lowpassvalue = mathf. lerp (lowpassvalue, input. acceleration, lowpassfilterfactor); Return lowpassvalue;
}