Search Unity

Turning to face the map ?

Discussion in 'AR/VR (XR) Discussion' started by TheDodgerUk1, Mar 16, 2018.

  1. TheDodgerUk1

    TheDodgerUk1

    Joined:
    Dec 3, 2013
    Posts:
    61
    SOLVED


    I have an issue which I could use some help
    I need to turn the plater to a map

    I am in a 3d world and wanted a mini map but i thought I would just use the map I am walking on

    So I put my self up in the air 100
    And I can see the map under me which is not good

    I had
    Person
    Camera

    The person only moves on X y z axis and never rotates
    The camera is where you are looking

    So I did
    Person
    Pivt point
    Camera

    I turn trt pivot point 90 on the X and I am pointing at the map
    Half way there

    Now I want to do, is when I press the minimal, the map is straight in front of were ever I am looking ,
    This part I cant get right , any help ?





    SOLVED
    void Update ()
    {
    Vector3 lCamera = m_Camera.transform.localRotation.eulerAngles;
    Vector3 lLookDown = new Vector3(-lCamera.x, lCamera.z, -lCamera.y);
    m_pivot.transform.localRotation = Quaternion.Euler(lLookDown);
    m_pivot.transform.Rotate(90, 0, 0);
    }
     
    Last edited: Mar 16, 2018
  2. StickyHoneybuns

    StickyHoneybuns

    Joined:
    Jan 16, 2018
    Posts:
    207
    What about it can you not get right? All you need to do is get the transform of the HMD which in this case is the main camera.

    This is the code that should be on your map. You will have to add to it but this is the idea:
    Code (CSharp):
    1. void OnButtonPress()
    2. {
    3. float distance = 10;//distance is a float of how far away you want the map to be
    4. transform.position = camera.main.position + new Vector3(Vector3.forward*distance);
    5. }
     
  3. TheDodgerUk1

    TheDodgerUk1

    Joined:
    Dec 3, 2013
    Posts:
    61

    I can't move the map at it has phsiphy on it
     
  4. StickyHoneybuns

    StickyHoneybuns

    Joined:
    Jan 16, 2018
    Posts:
    207
    Sorry, can you explain what phsiphy is?
     
  5. TheDodgerUk1

    TheDodgerUk1

    Joined:
    Dec 3, 2013
    Posts:
    61
    Sorry,. Physics

    I have solved it

    void Update ()
    {
    Vector3 lCamera = m_Camera.transform.localRotation.eulerAngles;
    Vector3 lLookDown = new Vector3(-lCamera.x, lCamera.z, -lCamera.y);
    m_pivot.transform.localRotation = Quaternion.Euler(lLookDown);
    m_pivot.transform.Rotate(90, 0, 0);
    }
     
    StickyHoneybuns likes this.