# World:rayCast

 Available since LÖVE 0.8.0 This method is not supported in earlier versions.

Casts a ray and calls a function for each fixtures it intersects.

## Function

### Synopsis

```World:rayCast( x1, y1, x2, y2, callback )
```

### Arguments

`number x1`
The x position of the starting point of the ray.
`number y1`
The y position of the starting point of the ray.
`number x2`
The x position of the end point of the ray.
`number y2`
The y position of the end point of the ray.
`function callback`
A function called for each fixture intersected by the ray. The function gets six arguments and should return a number as a control value. The intersection points fed into the function will be in an arbitrary order. If you wish to find the closest point of intersection, you'll need to do that yourself within the function. The easiest way to do that is by using the fraction value.

Nothing.

## Callback

### Synopsis

```control = callback( fixture, x, y, xn, yn, fraction )
```

### Arguments

`Fixture fixture`
The fixture intersecting the ray.
`number x`
The x position of the intersection point.
`number y`
The y position of the intersection point.
`number xn`
The x value of the surface normal vector of the shape edge.
`number yn`
The y value of the surface normal vector of the shape edge.
`number fraction`
The position of the intersection on the ray as a number from 0 to 1 (or even higher if the ray length was changed with the return value).

### Returns

`number control`
The ray can be controlled with the return value. A positive value sets a new ray length where 1 is the default value. A value of 0 terminates the ray. If the callback function returns -1, the intersection gets ignored as if it didn't happen.