<!--
{
  "availability" : [
    "iOS: 13.0.0 -",
    "iPadOS: 13.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "ARKit",
  "identifier" : "/documentation/ARKit/ARRaycastQuery",
  "metadataVersion" : "0.1.0",
  "role" : "Class",
  "symbol" : {
    "kind" : "Class",
    "modules" : [
      "ARKit"
    ],
    "preciseIdentifier" : "c:objc(cs)ARRaycastQuery"
  },
  "title" : "ARRaycastQuery"
}
-->

# ARRaycastQuery

A mathematical ray you use to find 3D positions on real-world surfaces.

```
class ARRaycastQuery
```

## Overview

You create a raycast query by providing a 3D vector and starting place.

To create a raycast query using a 2D screen location and default vector that casts outward in the z-direction from the user, use the convenience functions, <doc://com.apple.documentation/documentation/RealityKit/ARView/makeRaycastQuery(from:allowing:alignment:)> on <doc://com.apple.documentation/documentation/RealityKit/ARView>, or [`raycastQuery(from:allowing:alignment:)`](/documentation/ARKit/ARSCNView/raycastQuery(from:allowing:alignment:)) on [`ARSCNView`](/documentation/ARKit/ARSCNView).

Raycasts can intersect with planes (flat surfaces) or meshes (uneven surfaces). To intersect with planes, see [`ARRaycastQuery.Target`](/documentation/ARKit/ARRaycastQuery/Target-swift.enum). To intersect with meshes, see [`ARRaycastQuery.Target.estimatedPlane`](/documentation/ARKit/ARRaycastQuery/Target-swift.enum/estimatedPlane).

## Topics

### Creating a Raycast Query

[`init(origin:direction:allowing:alignment:)`](/documentation/ARKit/ARRaycastQuery/init(origin:direction:allowing:alignment:))

Creates a new raycast query.

### Specifying the Target

[`target`](/documentation/ARKit/ARRaycastQuery/target-swift.property)

A plane type that allows the raycast to terminate if it’s encountered.

[`ARRaycastQuery.Target`](/documentation/ARKit/ARRaycastQuery/Target-swift.enum)

The types of surface you allow a raycast to intersect with.

[`targetAlignment`](/documentation/ARKit/ARRaycastQuery/targetAlignment-swift.property)

The target’s alignment with respect to gravity.

[`ARRaycastQuery.TargetAlignment`](/documentation/ARKit/ARRaycastQuery/TargetAlignment-swift.enum)

A specification that indicates a target’s alignment with respect to gravity

### Interpreting the Ray

[`direction`](/documentation/ARKit/ARRaycastQuery/direction)

A vector that describes the ray’s trajectory in 3D space.

[`origin`](/documentation/ARKit/ARRaycastQuery/origin)

A 3D coordinate that defines the ray’s starting place.



---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)