Skip to content

Commit c6c4503

Browse files
committed
fix raycasting
1 parent 0824185 commit c6c4503

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

cave-game/server/entities/PlayerEntity.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -190,9 +190,13 @@ export class PlayerEntity extends Entity {
190190
lastFoundAnchor: GrappleAnchorEntity | null = null;
191191
lastAnchor: GrappleAnchorEntity | null = null;
192192
findGrappleAnchor(lookDir: YXZEuler): GrappleAnchorEntity | null {
193-
const dir = new phys.Vec3(-Math.sin(lookDir.y), Math.sin(lookDir.x), -Math.cos(lookDir.y)).unit();
193+
const dir = new phys.Vec3(
194+
-Math.sin(lookDir.y) * Math.cos(lookDir.x),
195+
Math.sin(lookDir.x),
196+
-Math.cos(lookDir.y) * Math.cos(lookDir.x),
197+
);
194198
const objects = this.game.raycast(
195-
this.body.position.vadd(dir.clone().scale(2)), // start the ray 2 units in front of the player
199+
this.body.position, //.vadd(dir.clone().scale(2)), // start the ray 2 units in front of the player
196200
dir.scale(100).vadd(this.body.position),
197201
{},
198202
this,

0 commit comments

Comments
 (0)