The Raycast node filters by collision layers: the node gained a "Layers" setting, a tickbox per collision layer of the project - the same field kind the collider uses for "Collides with" - and the ray only hits what sits on a ticked layer, tilemaps counting as colliders; the default is every layer, and a graph without the param answers exactly as before, which is its own unit test; the check is one-sided on purpose, unlike the symmetric rule of #152: a ray is not a collider, so it never reads the collidesWith of the thing it hits - a collider that meets nothing is still seen by a ray - because who a ray may look at is the ray's business, and a unit test holds that case; the filter sits in Solids.raycast in front of the intersection test, which is the one path the editor run and Play both take, so every unit test runs through describe.each against both systems; NodeView did not know the field kinds layer/layers, so the node would have read "Layers: 65533" - it now shows the name of the layer, or "All layers"; 5 new e2e checks in the new block 43d (a shield on its own layer between the caster and the floor stops the ray, the "Layers" row on the node, the tickbox menu with the project's layers, the ray reaching 280 instead of 145 units once the shield's layer is unticked, and the mask read as a name) and 6 new unit tests, three against each system; two counter-checks hold: disarming the filter line drops 6 unit tests and the unticking check in module 43, and switching the formatting off makes the node check fail with the raw bits; two findings from measuring came out of it and stand in the wiki and the notes - __gm.rays() only measures while the Scene tab is in front, so a node selection blinds it and the block measures through a Log node on distance instead, and a running behavior instance keeps the graph it started with, so the editor run casts with the old mask until the instance is built anew (#158)
game-maker / gate (push) Successful in 2m7s
game-maker / suite (push) Successful in 7m22s

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
adminandClaude Opus 5 committed 2026-09-20 18:15:35 +02:00
1 parent ae3aa7d3bd
commit 0fdde6cb1e
9 files changed
+214 -12

No files matched your search

+15 -4
View File
@@ -13,7 +13,12 @@ import {
solidRects,
} from '../../core/model/tilemapCollision';
import { parentChain } from '../../core/model/walk';
import { type CollisionFilter, collisionFilterOf, layersMeet } from '../../core/model/collisionLayers';
import {
type CollisionFilter,
collisionFilterOf,
layersMeet,
maskHas,
} from '../../core/model/collisionLayers';
import {
type ColliderShape,
colliderShape,
@@ -116,10 +121,15 @@ export interface RayResult {
distance: number;
}
/** Which colliders a ray looks at: all but those of `ignore` and below it, triggers only when asked. */
/**
* Which colliders a ray looks at: all but those of `ignore` and below it, triggers only when asked,
* and only what sits on a layer of `layers` (#158). That last one is one-sided on purpose – a ray is
* not a collider, so the collider's own "Collides with" has no say over who may look at it.
*/
export interface RayFilter {
ignore: Entity | null;
triggers: boolean;
layers: number;
}
/** Where a sweep stopped: what it met, with which own collider, the normal, and the move left over. */
@@ -222,8 +232,8 @@ export class Solids {
/**
* The first solid the ray from `from` along `direction` meets within `length` (world units): any
* blocking collider or tilemap cell, triggers when asked, a one-way one only on the side it blocks
* from. What the ray starts inside is not met (see `rayCast`).
* blocking collider or tilemap cell on one of the filter's layers (#158), triggers when asked, a
* one-way one only on the side it blocks from. What the ray starts inside is not met (see `rayCast`).
*/
raycast(world: World, from: Vec2, direction: Vec2, length: number, filter: RayFilter): RayResult | null {
const d = unitOf(direction);
@@ -233,6 +243,7 @@ export class Solids {
if (!isCollisionBody(body) || !isHandleEnabled(body)) continue;
if (body.type === 'collider' && isTrigger(body.props) && !filter.triggers) continue;
if (filter.ignore && travelsWith(body, filter.ignore)) continue;
if (!maskHas(filter.layers, collisionFilterOf(body.props).layer)) continue;
for (const { shape, facing } of this.solidShapesOf(world, body)) {
const hit = rayCast(shape, from, d, best?.distance ?? length);
if (!hit || (facing && !landsOn(hit.normal, facing))) continue;