Log in or register to post comments

trigger a video+sound in AR from a distance

February 17, 2020 - 12:20pm #1

Hello community! I am an art student and for my end of study project I realize a digital publishing project with postcards. I recently started using Unity2019.3 0f6 and Vuforia. My question is as follows: Is it possible to display an augmented reality video (+ sound) that is triggered at a certain distance from the paper medium?

When my phone is less than 20 cm from the paper, a video is triggered. When my phone is more than 20 cm from the paper, another video is triggered.

I am not a developer so if someone could help me I would be very grateful!

    Thks

trigger a video+sound in AR from a distance

February 17, 2020 - 2:40pm #2

Unfortunately it will take some code to do this but it is possible as long as the target is able to be tracked at the larger distance.  Code would look something like this:

public class NewBehaviourScript : MonoBehaviour
{
    // Start is called before the first frame update
Transform cam,target;
GameObject item1,item2;

void Start()
{
  cam = GameObject.Find("ARCamera").transform;
  target = GameObject.Find("MyImageTarget").transform;
 
  // Two game obejcts are children of the image target
  item1 = GameObject.Find("Item1");
  item2 = GameObject.Find("Item2");
  item1.SetActive(false);
  item2.SetActive(false);
    }
void Update()
{
  if (Vector3.Distance(cam.position,target.position)<0.2f)
  {
   item1.SetActive(true);
   item2.SetActive(false);
  }
  else
  {
   item1.SetActive(false);
   item2.SetActive(true);
  }
}
}





 

Log in or register to post comments