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 &&