Unity mobile devices face to face

Source: Internet
Author: User

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;
}

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.