From c5b5ce1fa0d5e5935abb5850b619c4c692e29b00 Mon Sep 17 00:00:00 2001 From: Mylloon Date: Sat, 3 Dec 2022 01:09:02 +0100 Subject: [PATCH] littles fixes --- js/Player.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/js/Player.js b/js/Player.js index 2f445da..a39dbf6 100644 --- a/js/Player.js +++ b/js/Player.js @@ -22,7 +22,7 @@ export class Player extends Cube { if (demo) { listEnnemies.forEach((ennemy) => { const pos = ennemy.position.x - this.data.position.x; - if (pos < Math.random() * 1.5 + 0.5 && pos > 0) { + if (pos > 0 && pos < Math.random() * 1.5 + 0.5) { dispatchEvent(jumpDemo); } }); @@ -105,13 +105,13 @@ export class Player extends Cube { const directionVector = globalVertex.sub(this.data.position); // Create the raycaster for this vector from the player position - const ray = new THREE.Raycaster( + const rc = new THREE.Raycaster( this.data.position, directionVector.clone().normalize() ); // Check if the raycaster hit ennemies - const collisionResults = ray.intersectObjects(listEnnemies, false); + const collisionResults = rc.intersectObjects(listEnnemies, false); if ( collisionResults.length > 0 && directionVector.length() < 1.5 &&