Hi all,
I’m having an issue detecting collision between two objects. Please help!
Code -
var Collider = pc.createScript('collider');
// initialize code called once per entity
Collider.prototype.initialize = function () {
this.entity.collision.on('collisionstart', this.onCollisionStart, this);
//name of 1st object
this.Entity1 = this.app.root.findByName('NewEntity');
//name of 2nd object
this.Entity2 = this.app.root.findByName('Barrier');
};
Collider.prototype.onCollisionStart = function (result) {
//Check to see if Entity1 has hit this object
if (result.other.name == this.Entity1) {
alert("you hit me!!");
}
};