[SOLVED] Help with collision detection

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!!");


this.Entity1 contains the whole object, not just a name.

in OnCollisionStart you compare it with a name which is string.

So, in a nutshell you have to do it like
resul.other.name == this.Entity1.name

Or even compare objects, not just a name.

Tried that, it works perfectly, thanks a lot for your help @mikefinch