Skip to content

Commit 14e07ce

Browse files
committed
update ingredients.
1 parent 572d100 commit 14e07ce

1 file changed

Lines changed: 45 additions & 1 deletion

File tree

combined-ingredients.md

Lines changed: 45 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1488,6 +1488,43 @@ export default class Enemy extends Behavior {
14881488
}
14891489
```
14901490

1491+
## Ray Casting
1492+
1493+
```ts
1494+
import RAPIER from "@dreamlab/vendor/rapier.ts";
1495+
1496+
// in your tick or wherever needed
1497+
let ray = new RAPIER.Ray({ x: 1.0, y: 2.0 }, { x: 0.0, y: 1.0 }); // direction of ray
1498+
let rayDistance = 4.0;
1499+
let solid = true; // hit inside of object if cast inside object, otherwise only treat walls as solid
1500+
1501+
this.game.physics.world.castRay(
1502+
leftRay,
1503+
rayDistance,
1504+
solid,
1505+
undefined,
1506+
undefined,
1507+
// ignore a specific collider
1508+
this.entity.cast(CharacterController).collider,
1509+
undefined,
1510+
// or write a filter, this one ignores the left wall
1511+
(collider) => {
1512+
const entity = this.game.entities.lookupByRef(collider.userData.entityRef);
1513+
if (entity && entity.name === "LeftWall") return false;
1514+
return true;
1515+
},
1516+
);
1517+
1518+
// undefined positional arguments above are less common filter methods.
1519+
1520+
// when raycasting from a player, you MUST filter out the player.
1521+
1522+
1523+
if (hit) {
1524+
const hitEntity: Entity = this.game.entities.lookupByRef(result!.collider.userData.entityRef)!;
1525+
}
1526+
```
1527+
14911528
---
14921529

14931530

@@ -1622,4 +1659,11 @@ If you make changes to behavior scripts, be sure to commit your changes using th
16221659

16231660
Feel free to do planning, but be concise as possible after making your code changes.
16241661

1625-
After making code change tool call, please limit your response to one or two sentences. Do not give a long description of your changes after making them.
1662+
After making code change tool call, please limit your response to one or two sentences. Do not give a long description of your changes after making them.
1663+
1664+
Be sure to look at scene-description.md and pay attention to the scale of objects when ray casting! If an object's x scale is 2 and you're casting from the center of it to see if it is touching something, you should have rayDistance of 1.1 since that's a little more than half.
1665+
1666+
VERY IMPORTANT: If you need any information about size/position of objects, read `scene-description.md` before starting work.
1667+
Eg: If the user asks for a wall jump to be added to the player, check the scale of the player by reading `scene-description.md`.
1668+
1669+
For efficiency, use as few find/replace tool calls as possible to accomplish your goals.

0 commit comments

Comments
 (0)