Ejemplo n.º 1
0
        protected override void OnTriggerEnter(Collider other)
        {
            base.OnTriggerEnter(other);

            if (CurrentInteractionObject != null)
            {
                // See if there is a velocity estimator, if not add one, since it is needed to track the user's velocity movements
                currentInteractingVelocityEstimator = CurrentInteractionObject.GetComponentInParent <VRTK_VelocityEstimator>();

                if (currentInteractingVelocityEstimator == null)
                {
                    // Add the velocity estimator to the GameObject holding the Rigidbody since it uses local positions to calculate its estimates
                    GameObject gameObjectRigidbody = CurrentInteractionObject.GetComponentInParent <Rigidbody>().gameObject;

                    if (gameObjectRigidbody != null)
                    {
                        addedVelocityEstimator = gameObjectRigidbody.AddComponent <VRTK_VelocityEstimator>();
                    }
                    // Otherwise, just add it to the current GameObject in the IA
                    else
                    {
                        addedVelocityEstimator = CurrentInteractionObject.gameObject.AddComponent <VRTK_VelocityEstimator>();
                    }

                    currentInteractingVelocityEstimator = addedVelocityEstimator;
                }
            }
        }
Ejemplo n.º 2
0
        protected override void OnTriggerExit(Collider collider)
        {
            base.OnTriggerExit(collider);

            if (addedVelocityEstimator != null)
            {
                Destroy(addedVelocityEstimator);
            }

            currentInteractingVelocityEstimator = null;
        }
Ejemplo n.º 3
0
 void Start()
 {
     velocityEst = GetComponent <VRTK_VelocityEstimator>();
 }