littles fixes

This commit is contained in:
Mylloon 2022-12-03 01:09:02 +01:00
parent 97e3cca3b2
commit c5b5ce1fa0
Signed by: Anri
GPG key ID: A82D63DFF8D1317F

View file

@ -22,7 +22,7 @@ export class Player extends Cube {
if (demo) { if (demo) {
listEnnemies.forEach((ennemy) => { listEnnemies.forEach((ennemy) => {
const pos = ennemy.position.x - this.data.position.x; 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); dispatchEvent(jumpDemo);
} }
}); });
@ -105,13 +105,13 @@ export class Player extends Cube {
const directionVector = globalVertex.sub(this.data.position); const directionVector = globalVertex.sub(this.data.position);
// Create the raycaster for this vector from the player position // Create the raycaster for this vector from the player position
const ray = new THREE.Raycaster( const rc = new THREE.Raycaster(
this.data.position, this.data.position,
directionVector.clone().normalize() directionVector.clone().normalize()
); );
// Check if the raycaster hit ennemies // Check if the raycaster hit ennemies
const collisionResults = ray.intersectObjects(listEnnemies, false); const collisionResults = rc.intersectObjects(listEnnemies, false);
if ( if (
collisionResults.length > 0 && collisionResults.length > 0 &&
directionVector.length() < 1.5 && directionVector.length() < 1.5 &&