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