How do I add the name of entity when disabling?

Hey, how do I add the name of the entity I want to disable, alongside the entity I want to enable at the same time?

var Collider2 = pc.createScript('collider2');

// initialize code called once per entity
Collider2.prototype.initialize = function () {
    this.entity.collision.on('collisionstart', this.onCollisionStart, this);
    this.entity.collision.on('collisionend', this.onCollisionEnd, this);

Collider2.prototype.onCollisionStart = function (result) {
    this.entity.enabled = false;

        this.entity.enabled = true;
    }.bind(this), 5000);

Hi @Koma! Your question is not clear to me. Can you rephrase it please?


so, on collision, I need the entity that the script is attached to disable while enabling another entity.

When you get the event to occur I believe you are passed (result). result contains the pointer to the other. i.e. result.other = other entity. You can then operate on enabled. Now if you are not actually colliding with the other object you could at the top of the code do this.

See this

Collider2.attributes.add(“otherObj”, { type: ‘entity’, title: ‘OtherObject’ });
Toss the other object into the attribute created. Then you could use this.otherObj.enabled = to true/false.


You could use…“OtherObjName”).enabled = true;

I have not tried this yet but I would disable this.entity after you enable otherObj. Hope this helps and answers your question.