littles fixes
This commit is contained in:
parent
97e3cca3b2
commit
c5b5ce1fa0
1 changed files with 3 additions and 3 deletions
|
@ -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 &&
|
||||
|
|
Reference in a new issue