Version: 2017.3
public static bool Linecast (Vector3 start, Vector3 end, int layerMask= DefaultRaycastLayers, QueryTriggerInteraction queryTriggerInteraction= QueryTriggerInteraction.UseGlobal);

Parámetros

start Punto inicial.
end Punto final.
layerMask Un Layer mask que es utilizado para ignorar colliders selectivamente cuando se emita un rayo.
queryTriggerInteraction Especifica si esta consulta debería golpear Triggers.

Descripción

Retorna true si hay cualquier collider que intersecta la linea entre start y end.

using UnityEngine;
using System.Collections;

public class ExampleClass : MonoBehaviour { public Transform target; void Update() { if (Physics.Linecast(transform.position, target.position)) { Debug.Log("blocked"); } } }

public static bool Linecast (Vector3 start, Vector3 end, out RaycastHit hitInfo, int layerMask= DefaultRaycastLayers, QueryTriggerInteraction queryTriggerInteraction= QueryTriggerInteraction.UseGlobal);

Parámetros

start Punto inicial.
end Punto final.
layerMask Un Layer mask que es utilizado para ignorar colliders selectivamente cuando se emita un rayo.
queryTriggerInteraction Especifica si esta consulta debería golpear Triggers.
hitInfo If true is returned, hitInfo will contain more information about where the collider was hit. (See Also: RaycastHit).

Descripción

Retorna true si hay cualquier collider que intersecta la linea entre start y end.

If true is returned, hitInfo will contain more information about where the collider was hit. (See Also: RaycastHit). Layer mask is used to selectively ignore colliders when casting a ray.