[SOLVED] How do I disable and entity upon tapping it?

I tried this:

var HideMeOnTap = pc.createScript('hideMeOnTap');

HideMeOnTap.prototype.initialize = function() {
    this.entity.element.on('touchend', this.OnTapped,this);

HideMeOnTap.prototype.onTapped = function (event) {
    this.entity.enabled = false;

…but nothing happens.


Hi @Grimmy,

Not sure what’s going on, are you testing this on mobile? If you are testing on a desktop make sure to add an event handler for the mouse.

Also make sure to enable Use Input in editor on the element component, otherwise input isn’t being activated for it.

1 Like

Yeah, I’m testing on mobile and I have got the ‘Use Input’ checkbox ticked too, but still nothing.

I also tried ticking this checkbox on the object’s parent too, but that makes no difference either way.


Not sure what’s the issue, try following this tutorial:


Hi @Grimmy! I don’t know if it matters, but the first letter of your function name in the event is an uppercase and the first letter of the actual function is no uppercase.

1 Like

Good spot and yes it does matter :slight_smile:

1 Like

Arrgh!!! Thank you!! That’s the one.

It was just a test…really :blush: