Search Unity

Finding the position of Andy in HelloAR and storing it to compare using ARCore?

Discussion in 'AR' started by Kanoza, Feb 20, 2019.

  1. Kanoza

    Kanoza

    Joined:
    Jan 21, 2019
    Posts:
    1
    Hi, I'm new to unity and I'm trying to make a simple function in the HelloARController script. In this script what I'm trying to do is store the position in which the Andy object is placed in the real world. I do this using this code in the Update() method:

    storePos.Add(hit.Pose.position);


    To my own understanding, hit.Pose.position is the 3D positioning of where the user taps the screen, relative to the real world space (I'm assuming. After some research I came to this conclusion. Please feel free to correct me!). So what I did was store those co-ordinates in a List<Vector3>. If the user were to hit or tap somewhere of the same co-ordinates again I just wanted to spawn a canvas. I do this by using a for loop to compare the hit position with the positions that were previously stored like this:

    for (int i = 0; i < storePos.Count; i++)
    {
    if (hit.Pose.position == storePos[i])
    {
    etc....
    }
    }


    When trying out this code, it doesn't work and I've thought of some reasons as to why but struggling to find a solution to this problem. Whilst continuing to figure this out, I would appreciate some advice, answers or tips! :)