---
title: "body(alongRayStart:end:)"
framework: spritekit
role: symbol
role_heading: Instance Method
path: "spritekit/skphysicsworld/body(alongraystart:end:)"
---

# body(alongRayStart:end:)

Searches for the first physics body that intersects a ray.

## Declaration

```swift
func body(alongRayStart start: CGPoint, end: CGPoint) -> SKPhysicsBody?
```

## Parameters

- `start`: The starting point for the ray in scene coordinates.
- `end`: The ending point for the ray in scene coordinates.

## Return Value

Return Value The first physics body discovered that intersects the ray. This may be any body along the ray; it is not guaranteed to be the closest physics body. If no body intersects the ray, this method returns nil.

## See Also

### Searching the Scene for Physics Bodies

- [Searching the World for Physics Bodies](spritekit/searching-the-world-for-physics-bodies.md)
- [body(at:)](spritekit/skphysicsworld/body(at:).md)
- [body(in:)](spritekit/skphysicsworld/body(in:).md)
- [enumerateBodies(alongRayStart:end:using:)](spritekit/skphysicsworld/enumeratebodies(alongraystart:end:using:).md)
- [enumerateBodies(at:using:)](spritekit/skphysicsworld/enumeratebodies(at:using:).md)
- [enumerateBodies(in:using:)](spritekit/skphysicsworld/enumeratebodies(in:using:).md)
