/**************************************************************************** * Copyright 2019 Nreal Techonology Limited. All rights reserved. * * This file is part of NRSDK. * * https://www.nreal.ai/ * *****************************************************************************/ namespace NRKernal.Experimental.NRExamples { using UnityEngine; /// A recyclable toys. public class RecyclableToys : NRGrabbableObject { /// The origin position. private Vector3 m_OriginPos; /// The origin rot. private Quaternion m_OriginRot; /// The minimum position y coordinate. private float m_MinPositionY = -1.8f; /// Starts this object. void Start() { m_OriginPos = transform.position; m_OriginRot = transform.rotation; } /// Updates this object. void Update() { if (transform.position.y < m_MinPositionY) RecycleSelf(); } /// Recycle self. private void RecycleSelf() { transform.position = m_OriginPos; transform.rotation = m_OriginRot; m_AttachedRigidbody.velocity = Vector3.zero; m_AttachedRigidbody.angularVelocity = Vector3.zero; } } }