var upPoleBBox = new pc.BoundingBox(this.upPole.getPosition(), this.upPole.sprite.aabb.halfExtents);
var downPoleBBox = new pc.BoundingBox(this.downPole.getPosition(), this.downPole.sprite.aabb.halfExtents);
var birdBBox = new pc.BoundingBox(this.bird.getPosition(), this.bird.sprite.aabb.halfExtents);
var rays = [
new pc.Ray(birdBBox.getMin(), pc.Vec3.DOWN), // bottom edge
new pc.Ray(birdBBox.getMax(), pc.Vec3.RIGHT), // right edge
new pc.Ray(birdBBox.getMax(), pc.Vec3.UP), // top edge
new pc.Ray(birdBBox.getMin(), pc.Vec3.LEFT) // left edge
];
for (var i = 0; i < rays.length; i++) {
if (upPoleBBox.intersectsRay(rays[i]) || downPoleBBox.intersectsRay(rays[i])) {
console.log("collision detected");
this.isHit = 1;
var GAME = this.app.root.findByTag("game");
var GAMEOVER = this.app.root.findByTag("go");
GAME[0].enabled = false;
setTimeout(function () {
GAMEOVER[0].enabled = true;
}, 350);
}
}
This code isn’t working fine. Is there any modifications that I need to do ?