Ejemplo n.º 1
0
        public static float Raycast(Transform transform, float raycast_distance, int raycast_layerMask, float angle)
        {
            float dist = raycast_distance;

            Vector3      direction = transform.TransformDirection(MathfExt.DegreeToVector2(angle));
            RaycastHit2D raycast   = Physics2D.Raycast(transform.position, direction, raycast_distance, raycast_layerMask);

            if (raycast.collider != null)
            {
                dist = raycast.distance;
            }
            Debug.DrawRay(transform.position, direction * raycast.distance, Color.red);

            return(dist);
        }