Search Unity

How to get AR Foundation ARCamera to interact with collider triggers?

Discussion in 'Handheld AR' started by ethanproia, Jun 14, 2019.

  1. ethanproia

    ethanproia

    Joined:
    Feb 27, 2019
    Posts:
    7
    Hello all,
    Working on a location-based AR experience in AR Foundation. I'm trying to make UI text trigger when the ARCamera (user position) interacts with a box collider trigger attached to a placed object.

    The object I'm placing that I want to act as the movable trigger is a prefab for the provided PlaceOnPlane script. I've written a second script telling the collider to trigger a specified UI text when the ARCamera tagged MainCamera intersects with the placed object collider/trigger. For some reason, the ARCamera, even when tagged with the proper tag as directed by my script, will not register or display the text or register the collision. Can the ARCamera not be used to interact with colliders or trigger objects? I've got rigidbodies on the collider/trigger and the ARCamera.

    The code for the trigger/collider is

    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4.  
    5. public class PoemTrigger : MonoBehaviour {
    6.  
    7.     public GameObject poemText;
    8.     void Start()
    9.     {
    10.         poemText.SetActive(false);
    11.     }
    12.     void OnTriggerEnter(Collider camera)
    13.     {
    14.         if (camera.gameObject.tag == "MainCamera")
    15.         {
    16.             poemText.SetActive(true);
    17.             StartCoroutine("WaitForSec");
    18.         }
    19.     }
    20.     IEnumerator WaitForSec()
    21.     {
    22.         yield return new WaitForSeconds(5);
    23.         Destroy(poemText);
    24.     }
    25. }
    Been stuck on how to solve this for a few days now. Any help or suggestions would be very appreciated. Thank you!
     
    eaglecondor and vovo801 like this.