<!--
{
  "availability" : [
    "iOS: 8.0.0 - 26.0.0",
    "iPadOS: 8.0.0 - 26.0.0",
    "macCatalyst: 13.1.0 - 26.0.0",
    "macOS: 10.8.0 - 26.0.0",
    "tvOS: 9.0.0 - 26.0.0",
    "visionOS: 1.0.0 - 26.0.0",
    "watchOS: 3.0.0 - 26.0.0"
  ],
  "documentType" : "symbol",
  "framework" : "SceneKit",
  "identifier" : "/documentation/SceneKit/SCNNode/hitTestWithSegment(from:to:options:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "SceneKit"
    ],
    "preciseIdentifier" : "c:objc(cs)SCNNode(im)hitTestWithSegmentFromPoint:toPoint:options:"
  },
  "title" : "hitTestWithSegment(from:to:options:)"
}
-->

# hitTestWithSegment(from:to:options:)

Searches the node’s child node subtree for objects intersecting a line segment between two specified points.

```
func hitTestWithSegment(from pointA: SCNVector3, to pointB: SCNVector3, options: [String : Any]? = nil) -> [SCNHitTestResult]
```

## Parameters

`pointA`

An endpoint of the line segment to search along, specified in the node’s local coordinate system.

`pointB`

The other endpoint of the line segment to search along, specified in the node’s local coordinate system.

`options`

A dictionary of options affecting the search. See Hit Testing Options Keys for acceptable values.

## Return Value

An array of [`SCNHitTestResult`](/documentation/SceneKit/SCNHitTestResult) objects representing search results.

## Discussion

Hit-testing is the process of finding elements of a scene located along a specified line segment in the scene’s coordinate space (or that of a particular node in the scene). For example, you can use this method to determine whether a projectile launched by a game character will hit its target.

To search for the scene element corresponding to a two-dimensional point in the rendered image, use the renderer’s [`hitTest(_:options:)`](/documentation/SceneKit/SCNSceneRenderer/hitTest(_:options:)) method instead.

---

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)