Search Unity

Resolved Video autoplay on tracking/limited

Discussion in 'Unity MARS' started by Ricardotlpz, Jun 11, 2021.

  1. Ricardotlpz

    Ricardotlpz

    Joined:
    May 17, 2021
    Posts:
    63
    Hey there!

    I've had a bit of trouble making a video autoplay on AR. It is working "properly" with a reused script that initiates playback when touched with a raycast, but it would be best if it's autoplayed when tracked by the AR app.

    I've been thinking it could be done through the TrackingStateCondition with a script, but can't manage to find an example on how to do it. Appreciate if someone knows how to.
     
  2. CiaranWills

    CiaranWills

    Unity Technologies

    Joined:
    Apr 24, 2020
    Posts:
    199
    You could maybe just start playback when the object is instantiated by the proxy. Or register with the Proxy's MatchChanged event to know when the state changes.
     
    Ricardotlpz likes this.
  3. jmunozarUTech

    jmunozarUTech

    Unity Technologies

    Joined:
    Jun 1, 2020
    Posts:
    297
    You could implement the `IMatchAcquireHandler` and `IMatchLossHandler` interfaces to know if that proxy gets matched or not. Just add this script to your proxy with the tracking state condition and you will see it printing on the console when It gets matched and goes lost.

    Code (CSharp):
    1. Code (CSharp):
    2.  
    3.     using Unity.MARS.Query;
    4.     using UnityEngine;
    5.  
    6.     public class CheckTracking : MonoBehaviour, IMatchAcquireHandler, IMatchLossHandler
    7.     {
    8.         public void OnMatchAcquire(QueryResult queryResult)
    9.         {
    10.             Debug.Log("Matched!");
    11.         }
    12.  
    13.         public void OnMatchLoss(QueryResult queryResult)
    14.         {
    15.             Debug.Log("Lost!");
    16.         }
    17.     }
     
    Ricardotlpz likes this.
  4. Ricardotlpz

    Ricardotlpz

    Joined:
    May 17, 2021
    Posts:
    63
    Thanks guys! Managed to solve the issue :)
     
    jmunozarUTech likes this.