---
title: "raycast(from:allowing:alignment:)"
framework: realitykit
role: symbol
role_heading: Instance Method
path: "realitykit/arview/raycast(from:allowing:alignment:)"
---

# raycast(from:allowing:alignment:)

Performs a ray cast, where a ray is cast into the scene from the center of the camera through a point in the view, and the results are immediately returned.

## Declaration

```swift
@MainActor @preconcurrency func raycast(from point: CGPoint, allowing target: ARRaycastQuery.Target, alignment: ARRaycastQuery.TargetAlignment) -> [ARRaycastResult]
```

## Parameters

- `point`: A point in the view’s local coordinate system.
- `target`: The type of target where the ray should terminate.
- `alignment`: The alignment of the target.

## Return Value

Return Value A list of ray-cast results, sorted from nearest to farthest from the camera. The list is empty if the ray cast fails.

## See Also

### Finding entities at a point in the view

- [entity(at:)](realitykit/arview/entity(at:).md)
- [entities(at:)](realitykit/arview/entities(at:).md)
- [hitTest(_:query:mask:)](realitykit/arview/hittest(_:query:mask:).md)
- [hitTest(_:types:)](realitykit/arview/hittest(_:types:).md)
- [makeRaycastQuery(from:allowing:alignment:)](realitykit/arview/makeraycastquery(from:allowing:alignment:).md)
- [trackedRaycast(from:allowing:alignment:updateHandler:)](realitykit/arview/trackedraycast(from:allowing:alignment:updatehandler:).md)
