Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Bug AR Foundation device camera orientation vs AR camera orientation

Discussion in 'AR' started by highpockets, Nov 30, 2020.

  1. highpockets

    highpockets

    Joined:
    Jan 17, 2013
    Posts:
    71
    Hello,

    I'm using the below code to try to ensure the correct orientation of the said transform in relationship to the camera (tested on various iPhones). It always works fine when the iPhone is vertical (camera lens on top), but the moment I turn the phone, it is as if the AR camera is not updating the orientation with the device camera because the transform that the below code refers to does not rotate with the device camera when testing on the device, but it works as expected in the editor.

    I'm thinking that this might be because I have my app set to portrait mode, does that affect the AR - device camera tracking??

    Code (CSharp):
    1. private void Update()
    2. {
    3.     transform.rotation = Quaternion.LookRotation( _cam.transform.position - transform.position, _cam.transform.up );
    4. }
     
    Last edited: Nov 30, 2020
  2. KyryloKuzyk

    KyryloKuzyk

    Joined:
    Nov 4, 2013
    Posts:
    1,128
    Could you please show some screenshots? If autorotation is enabled on your AR device, AR camera's UP vector should always follow the device's UP vector regardless of the orientation.
    For example, this is landscape:
    upload_2020-12-1_16-6-55.png

    And this is portrait:
    upload_2020-12-1_16-7-23.png

    As you see, camera UP is always pointing up.