···6677[[Ray]]'s are a useful tool for testing if geometry intersects a line of sight with [[Collider.rayCast]]. You can think of them as a point in space with a direction.
8899+Examples where ray casting can be useful
1010+* Custom physics implementations (platformers, slopes, etc)
1111+* Line of sight AI
1212+* Proximity detection
1313+1414+:::warning
1515+1616+If you start a raycast from inside an [[Actor]] it will hit that Actor first unless you explicitly exclude it. See Raycast Options below.
1717+1818+:::
1919+2020+## Scene Testing
2121+2222+It is possible to test against all actors in a [[Scene]] at once.
2323+2424+```typescript
2525+2626+// given a scene reference
2727+const game = new ex.Engine({...});
2828+game.start();
2929+3030+3131+const ray = new ex.Ray(ex.vec(100, 100), ex.Vector.Right);
3232+game.currentScene.physics.rayCast(ray, {...});
3333+3434+// or in a custom scene
3535+class MyScene extends ex.Scene {
3636+3737+ someRayTestMethod() {
3838+3939+ const ray = new ex.Ray(ex.vec(100, 100), ex.Vector.Right);
4040+ this.physics.rayCast(ray, {...});
4141+ }
4242+}
4343+4444+```
4545+4646+## Scene Raycast Options
4747+4848+Excalibur's raycast can be optionally configured in a variety of ways. By default if no options are provided to the `rayCast(ray, ...)` the options will be
4949+5050+```typescript
5151+const hits = scene.physics.rayCast(ray, {
5252+ searchAllColliders: true,
5353+ collisionGroup: CollisionGroup.All,
5454+ collisionMask: CollisionGroup.All.mask,
5555+ ignoreCollisionGroupAll: false,
5656+ maxDistance: Infinity,
5757+ filter: null,
5858+})
5959+```
6060+6161+### Search All Colliders
6262+6363+By default the raycast will not stop after the first hit is found, if you'd like to only get the first hit set `searchAllColliders: false`
6464+6565+### Max Distance
6666+6767+Distance is in terms of pixels, this is the maximum length along the ray to search for colliders.
6868+6969+### Hit Filtering
7070+7171+Using the `filter` option you can do complex filtering logic to reject or accept potential hits.
7272+7373+```typescript
7474+scene.physics.rayCast(ray, {
7575+ filter: (potentialHit: RayCastHit) => {
7676+ // return true to accept the hit
7777+ // return false to reject the hit
7878+ return true;
7979+ }
8080+})
8181+```
8282+8383+### Collision Mask
8484+8585+The collision mask it a bit mask with a 1 in the place for each collision group category you'd like to consider in the raycast. For example this is useful if all your enemies share a collision group category. See [collision group documentation](/docs/collisiongroups/) for more information.
8686+8787+You may want to pair this with `ignoreCollisionGroupAll: true` to avoid default actors which collide with everything including specific rayCast masks.
8888+8989+```typescript
9090+const playerGroup = new ex.CollisionGroup('player', 0b0001, ~0b0001);
9191+const enemyGroup = new ex.CollisionGroup('enemy', 0b0010, ~0b0010);
9292+...
9393+9494+// this raycast will only actors with the 1 in the second place, so enemyGroup
9595+const enemyHits = scene.physics.rayCast(ray, {
9696+ collisionMask: 0b0010;
9797+});
9898+9999+// this raycast will only actors with the 1 in the first and second place, so playerGroup and enemyGroup
100100+const playerAndEnemyHits = scene.physics.rayCast(ray, {
101101+ collisionMask: 0b0011;
102102+});
103103+```
104104+105105+### Collision Group
106106+107107+The `collisionGroup` searches for actors that match a specific collision group.
108108+109109+You may want to pair this with `ignoreCollisionGroupAll: true` to avoid default actors which collide with everything including specific rayCast groups.
110110+111111+## Specific Actor Geometry Testing
112112+113113+If you have a specific actor or geometry that you know you will test against, all [[Collider]] types implement `rayCast(ray, [maxDistance])`.
114114+9115```typescript
10116const actor = new ex.Actor({
11117 pos: ex.vec(200, 100),