Search Unity

ARKit: Understanding Scale/Positioning

Discussion in 'AR' started by mika_gmr, Jul 5, 2018.

  1. mika_gmr

    mika_gmr

    Joined:
    Jul 5, 2018
    Posts:
    1
    Hi all.

    I have a small question and there has to be an easy solution. Probably I am stuck in the rut...

    Explanation:
    I have an object and want to set the Camera to a specific position in the object. This is the method I use to position the camera:

    Code (CSharp):
    1.  
    2. // Pseudo Code:
    3. void SetPosition(){
    4. 
        // Reset scale to 1 .
    5.         // I use the Fingers Plugin and handle the zoom via a method who sets the arController.scale
    6. 
        arController.scale = 1;
    7. 
        var camPlaceholder = new Vector3(-0.2f, 0.9f, 0.45f);
       
      
    8.         arController.pointOfInterest = camPlaceholder;
    9.         arController.AlignWithPointOfInterest(camPlaceholder);
    10.  
    11.         // Rotate the camera

    12.         // arController.rotation = Quaternion.LookRotation(-(model.transform.right), model.transform.up);

    13. }
    14.  
    My AR scale range is from 1 to 12.

    When the scene has the scale 12 I get the right position with my method. But in every other scale, the position is wrong. Scale 11 is the nearest to camPlaceholder and scale 1 is the farthest away.

    This behavior seems logical to me when I do not set the scale in my method.

    Please, could you give me a little hint about my wrong train of thoughts?

    Thank you in advance
     
    Last edited: Jul 5, 2018