As far as I know, I must have some objects with rigid body’s and collisions but, can someone help me in this?
I’ve “n” objects with animations (actually 6 objects) and I want to detect each collision, but I added the collision script to my main object (which I’m controlling).
I tried this in my main object:
var Colliders = pc.createScript('colliders');
// initialize code called once per entity
Colliders.prototype.initialize = function() {
// Each of this objects has a collision and rigid body
this.entity.collision.on('collisionstart', this.onCollision, this);
this.model1 = this.app.root.findByName('Man');
this.model2 = this.app.root.findByName('Man02');
this.model3 = this.app.root.findByName('Man03');
this.model4 = this.app.root.findByName('Man04');
this.model5 = this.app.root.findByName('Man05');
this.model6 = this.app.root.findByName('Man06');
};
Colliders.prototype.onCollision = function (result) {
console.log(result.other.name);
};
But at the moment that my main object collided with any object, the console log is not printed and if I add this collision script to each object instead of in my main object, the console log is printed. Sorry for my misspelling.