Phaser API Documentation

  Version: 
intersectRay(x1, y1, x2, y2, [rayWidth], [bodies])

Description:

Checks the given ray segment to see if any vertices of the given bodies intersect with it.

If no bodies are provided it will search all bodies in the Matter World.

The width of the ray can be specified via the rayWidth parameter.

Parameters:

name type arguments Default description
x1 number

The horizontal coordinate of the start of the ray segment.

y1 number

The vertical coordinate of the start of the ray segment.

x2 number

The horizontal coordinate of the end of the ray segment.

y2 number

The vertical coordinate of the end of the ray segment.

rayWidth number <optional> 1

The width of the ray segment.

bodies Array.<Phaser.Types.Physics.Matter.MatterBody> <optional>

An array of bodies to check. If not provided it will search all bodies in the world.

Returns:
Description:

An array of bodies whos vertices intersect with the ray segment.

Since: 3.22.0