Search Unity

Question How to use QR code to instatntiate 3D object in AR app in Unity?

Discussion in 'AR' started by Ar_begginer, Apr 30, 2021.

  1. Ar_begginer

    Ar_begginer

    Joined:
    Feb 7, 2021
    Posts:
    3
    So far I instatntiate 3d objects in my android app (using AR Foundation) using screen touch but now I want to use QR codes as markers for object placement. Is ti possible to do that, is there any C# code or working example showing the proccedure?

    Code (CSharp):
    1. if (GestureTransformationUtility.Raycast(gesture.startPosition, _hits, UnityEngine.XR.ARSubsystems.TrackableType.PlaneWithinPolygon))
    2.     {
    3.         placedObj = Instantiate(DataHandler.Instance.GetFurniture(), pose.position, pose.rotation);
    4.  
    5.         var anchorObject = new GameObject("PlacementAnchor");
    6.         anchorObject.transform.position = pose.position;
    7.         anchorObject.transform.rotation = pose.rotation;
    8.         placedObj.transform.parent = anchorObject.transform;
    9.     }
     
  2. eugeneloza

    eugeneloza

    Joined:
    Dec 3, 2019
    Posts:
    24
  3. umairs3031

    umairs3031

    Joined:
    Jul 31, 2023
    Posts:
    1
    I am working in a project in which i want to scan a QR code and get 3-d model projected there which is developed using unity