---
title: "hitTest(point:in:query:mask:)"
framework: realitykit
role: symbol
role_heading: Instance Method
path: "realitykit/realitycoordinatespaceprojecting/hittest(point:in:query:mask:)"
---

# hitTest(point:in:query:mask:)

Searches the scene for entities at the specified point in the view.

## Declaration

```swift
func hitTest(point: CGPoint, in space: some CoordinateSpaceProtocol, query: CollisionCastQueryType, mask: CollisionGroup) -> [CollisionCastHit]
```

## Parameters

- `point`: A point in the provided coordinate space.
- `space`: The 2D coordinate space in which to interpret the point.
- `query`: The query type.
- `mask`: The collision mask that you can use to prevent hits with certain objects. The default value is doc://com.apple.RealityKit/documentation/RealityKit/CollisionGroup/all, which means the ray can hit all objects. See doc://com.apple.RealityKit/documentation/RealityKit/CollisionFilter for details.

## Return Value

Return Value An array of hit-test results.

## Discussion

Discussion important: RealityKit performs hit tests (ray-casts) against collision shapes. Entities without a proper CollisionComponent are ignored by hit tests.
