# RaycastCommand

> Create a RaycastCommand.

## Definition

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

## RaycastCommand(Vector3, Vector3, QueryParameters, float)

Create a RaycastCommand.

```csharp
public RaycastCommand(Vector3 from, Vector3 direction, QueryParameters queryParameters, float distance = 3.4028235E+38)
```

### Parameters

**** (\[Vector3]\(/engine/6000.0/script-reference/unityengine/vector3)): The starting point of the ray in world coordinates.**** (\[Vector3]\(/engine/6000.0/script-reference/unityengine/vector3)): The direction of the ray.**** (\[QueryParameters]\(/engine/6000.0/script-reference/unityengine/queryparameters)): Structure for specifying additional parameters for a batch query such as layer mask, hit multiple mesh faces, hit triggers and hit backfaces.**** (\[float]\(https\://learn.microsoft.com/dotnet/api/system.single)): The maximum distance the ray should check for collisions.

### Remarks

The query is run in the default physics scene.

## RaycastCommand(PhysicsScene, Vector3, Vector3, QueryParameters, float)

Create a RaycastCommand.

```csharp
public RaycastCommand(PhysicsScene physicsScene, Vector3 from, Vector3 direction, QueryParameters queryParameters, float distance = 3.4028235E+38)
```

### Parameters

**** (\[PhysicsScene]\(/engine/6000.0/script-reference/unityengine/physicsscene)): The physics scene to run the raycast query in.**** (\[Vector3]\(/engine/6000.0/script-reference/unityengine/vector3)): The starting point of the ray in world coordinates.**** (\[Vector3]\(/engine/6000.0/script-reference/unityengine/vector3)): The direction of the ray.**** (\[QueryParameters]\(/engine/6000.0/script-reference/unityengine/queryparameters)): Structure for specifying additional parameters for a batch query such as layer mask, hit multiple mesh faces, hit triggers and hit backfaces.**** (\[float]\(https\://learn.microsoft.com/dotnet/api/system.single)): The maximum distance the ray should check for collisions.

## RaycastCommand(Vector3, Vector3, float, int, int)

Create a RaycastCommand.

> **Warning:**
>
> **Deprecated.** This struct signature is no longer supported. Use struct with a QueryParameters instead

```csharp
public RaycastCommand(Vector3 from, Vector3 direction, float distance = 3.4028235E+38, int layerMask = -5, int maxHits = 1)
```

### Parameters

**** (\[Vector3]\(/engine/6000.0/script-reference/unityengine/vector3)): The starting point of the ray in world coordinates.**** (\[Vector3]\(/engine/6000.0/script-reference/unityengine/vector3)): The direction of the ray.**** (\[float]\(https\://learn.microsoft.com/dotnet/api/system.single)): The maximum distance the ray should check for collisions.**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): A [LayerMask](/engine/6000.0/script-reference/unityengine/layermask.md) that is used to selectively ignore Colliders when casting a ray.**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): The maximum number of Colliders the ray can hit.

### Remarks

The query is run in the default physics scene.

## RaycastCommand(PhysicsScene, Vector3, Vector3, float, int, int)

Create a RaycastCommand.

> **Warning:**
>
> **Deprecated.** This struct signature is no longer supported. Use struct with a QueryParameters instead

```csharp
public RaycastCommand(PhysicsScene physicsScene, Vector3 from, Vector3 direction, float distance = 3.4028235E+38, int layerMask = -5, int maxHits = 1)
```

### Parameters

**** (\[PhysicsScene]\(/engine/6000.0/script-reference/unityengine/physicsscene)): The physics scene to run the raycast query in.**** (\[Vector3]\(/engine/6000.0/script-reference/unityengine/vector3)): The starting point of the ray in world coordinates.**** (\[Vector3]\(/engine/6000.0/script-reference/unityengine/vector3)): The direction of the ray.**** (\[float]\(https\://learn.microsoft.com/dotnet/api/system.single)): The maximum distance the ray should check for collisions.**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): A [LayerMask](/engine/6000.0/script-reference/unityengine/layermask.md) that is used to selectively ignore Colliders when casting a ray.**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): The maximum number of Colliders the ray can hit.
