unity3d - adding multiple objects in a single target in vuforia


Keywords:unity3d 


Question: 

i am a newbie in Augmented Reality, i am using Vuforia to build my AR apps. I want to add multiple objects on a single target. i would like to know how to make it possible.

Thank you in advance


1 Answer: 

One way of doing it is adding a spawn point as a child of the image target.

Then create a script say 'spawner.cs'

using UnityEngine;
using UnityEngine.UI;
using System.Collections;

public class spawner : MonoBehaviour
{

    public GameObject[] objToBePlaced;
    public GameObject spawnPt;      //the game object (spawn point on img target)

    private GameObject someobj;
    private int rno;

    void start()
    {
       rno = Random.Range(0,3);         //Random Range for selecting gameobjects
       someobj = (GameObject)Instantiate(objToBePlaced[rno],spawnPt.transform.position, Quaternion.identity);
    }
}

This will enable you to spawn game objects after you add spawn point & the objects in the editor. I am generating them randomly & also considering the spawn object are 4. However you can change it.