# Linecast

> Returns true if there is any collider intersecting the line between start and end.

## Definition

* **Type:** Method
* **Namespace:** [UnityEngine](/engine/6000.5/script-reference/unityengine.md)
* **Assembly:** UnityEngine.PhysicsModule

## Linecast(Vector3, Vector3, int, QueryTriggerInteraction)

Returns true if there is any collider intersecting the line between `start` and `end`.

```csharp
public static bool Linecast(Vector3 start, Vector3 end, int layerMask, QueryTriggerInteraction queryTriggerInteraction)
```

### Parameters

**** (\[Vector3]\(/engine/6000.5/script-reference/unityengine/vector3)): Start point.**** (\[Vector3]\(/engine/6000.5/script-reference/unityengine/vector3)): End point.**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): A Layer mask that is used to selectively filter which colliders are considered when casting a ray.**** (\[QueryTriggerInteraction]\(/engine/6000.5/script-reference/unityengine/querytriggerinteraction)): Specifies whether this query should hit Triggers.

### Returns

| Type                                                          | Description |
| ------------------------------------------------------------- | ----------- |
| [bool](https://learn.microsoft.com/dotnet/api/system.boolean) |             |

### Examples

```csharp
using UnityEngine;
using System.Collections;

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

## Linecast(Vector3, Vector3, RaycastHit, int, QueryTriggerInteraction)

Returns true if there is any collider intersecting the line between `start` and `end`.

```csharp
public static bool Linecast(Vector3 start, Vector3 end, out RaycastHit hitInfo, int layerMask, QueryTriggerInteraction queryTriggerInteraction)
```

### Parameters

**** (\[Vector3]\(/engine/6000.5/script-reference/unityengine/vector3)): Start point.**** (\[Vector3]\(/engine/6000.5/script-reference/unityengine/vector3)): End point.**** (\[RaycastHit]\(/engine/6000.5/script-reference/unityengine/raycasthit)): If true is returned, `hitInfo` will contain more information about where the collider was hit. (Additional Resources: [RaycastHit](/engine/6000.5/script-reference/unityengine/raycasthit.md)).**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): A Layer mask that is used to selectively filter which colliders are considered when casting a ray.**** (\[QueryTriggerInteraction]\(/engine/6000.5/script-reference/unityengine/querytriggerinteraction)): Specifies whether this query should hit Triggers.

### Returns

| Type                                                          | Description |
| ------------------------------------------------------------- | ----------- |
| [bool](https://learn.microsoft.com/dotnet/api/system.boolean) |             |

### Remarks

If true is returned, `hitInfo` will contain more information about where the collider was hit. (Additional Resources: [RaycastHit](/engine/6000.5/script-reference/unityengine/raycasthit.md)). [Layer mask](/engine/6000.5/manual/working-with-gameobjects/layers.md) is used to selectively ignore colliders when casting a ray.
