Пример #1
0
        /// <summary>
        /// Returns a contacted GameObject if we have touched a floor using a specific ray length.
        /// </summary>
        public static ContactConnection <GameObject> Floor(this HUMRaycast.Data.Touching touchData, float length)
        {
            Vector3 origin = new Vector3(
                touchData.origin.x,
                touchData.origin.y,
                touchData.origin.z
                );

            Debug.DrawRay(origin, Vector3.down, Color.red);
            return(Environment(touchData, Vector3.down, length));
        }
Пример #2
0
        /// <summary>
        /// Returns a contacted GameObject if we have touched an object, and got back an object with the tag "Environment".
        /// </summary>
        public static ContactConnection <GameObject> Environment(this HUMRaycast.Data.Touching touchData, Vector3 direction)
        {
            RaycastHit[] hit = Physics.RaycastAll(touchData.origin, direction);

            for (int i = 0; i < hit.Length; i++)
            {
                if (hit[i].collider.tag == "Environment")
                {
                    return(new ContactConnection <GameObject>(hit[i].collider.gameObject));
                }
            }

            return(new ContactConnection <GameObject>(null));
        }