﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class DistroyObjectAtDistance : MonoBehaviour
{

    // add to a game object with a rigidbody to distroy 
    // to distroy it when it reaches a specific distance  




    /*************************************************************************
* 
* ARConnex
* __________________
* 
*  [2017] - [2020] ARConnex Incorporated 
*  All Rights Reserved.
* 
* NOTICE:  All information contained herein is, and remains
* the property of ARConnex Incorporated and its suppliers,
* if any.  The intellectual and technical concepts contained
* herein are proprietary to ARConnex Incorporated
* and its suppliers and may be covered by U.S. and Foreign Patents,
* patents in process, and are protected by trade secret or copyright law.
* Dissemination of this information or reproduction of this material
* is strictly forbidden unless prior written permission is obtained
* from ARConnex Incorporated or if used for display in the ARConnex Reality Browser.
*/

    // add to a rigidbody to distroy  
    // when it reaches a specific distance 

    public float distanceInUnits;
    Vector3 startposition;
    private void Start()
    {
        startposition=gameObject.transform.position;
    }    
    void LateUpdate()
    {
        var distance = Vector3.Distance(gameObject.transform.position, startposition);
        if (distance > distanceInUnits)
        {
            Destroy(gameObject);
        }
    }

}
