<!--
{
  "availability" : [
    "iOS: -",
    "iPadOS: -",
    "macCatalyst: -",
    "macOS: -",
    "tvOS: -",
    "visionOS: -",
    "watchOS: -"
  ],
  "documentType" : "symbol",
  "framework" : "SpriteKit",
  "identifier" : "/documentation/SpriteKit/SKPhysicsWorld/enumerateBodies(alongRayStart:end:using:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "SpriteKit"
    ],
    "preciseIdentifier" : "c:objc(cs)SKPhysicsWorld(im)enumerateBodiesAlongRayStart:end:usingBlock:"
  },
  "title" : "enumerateBodies(alongRayStart:end:using:)"
}
-->

# enumerateBodies(alongRayStart:end:using:)

Enumerates all the physics bodies in the scene that intersect a ray.

```
func enumerateBodies(alongRayStart start: CGPoint, end: CGPoint, using block: @escaping (SKPhysicsBody, CGPoint, CGVector, UnsafeMutablePointer<ObjCBool>) -> Void)
```

## Parameters

`start`

The starting point for the ray in scene coordinates.

`end`

The ending point for the ray in scene coordinates.

`block`

A block to be called for each physics body that the ray touches. The block takes the following parameters:

- body:
  The physics body that the ray intersected.
- point:
  The point in scene coordinates where the ray contacted the physics body.
- normal:
  The normal vector for the physics body at the point of contact.
- stop:
  A pointer to a Boolean variable. Your block can set this to <doc://com.apple.documentation/documentation/Swift/true> to terminate the enumeration.

---

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)