Beispiel #1
0
        public virtual float DistanceFromController(ProximityController controller)
        {
            Vector3 position         = controller.InteractionSourceTransform().position;
            float   shortestDistance = float.MaxValue;

            foreach (Collider collider in GetComponentsInChildren <Collider>())
            {
                Vector3 closest  = collider.ClosestPointOnBounds(position);
                float   distance = (closest - position).magnitude;              // Vector3.Distance (AttachPosition (), closest);

                if (distance < shortestDistance)
                {
                    shortestDistance = distance;
                }
            }
            return(shortestDistance);
        }
Beispiel #2
0
 public override float DistanceFromController(ProximityController controller)
 {
     return((controller.InteractionSourceTransform().position - transform.position).magnitude);
 }