What entity method responds to touch controller touch?


#1

I’m starting to teach myself some basic scripting, but can’t figure out what method gets triggered from a controller touch. I found this script in the documentation which works fine with a mouse touch, but not the controller trigger.

// changeColorOnClickDown.js
(function () {
var clicked = false;
this.clickDownOnEntity = function (entityID, mouseEvent) {
if (clicked){
Entities.editEntity(entityID, { color: { red: 0, green: 255, blue: 255} });
clicked = false;
} else {
Entities.editEntity(entityID, { color: { red: 255, green: 255, blue: 0} });
clicked = true;
}
};
})

The documentation says ‘clickdownonEntity’ doesn’t get triggered by the touch controllers, but doesn’t say what does.

I must be missing something really obvious here. I’ve made sure the entity is set as triggerable in it’s properties.

Thanks!


#2

Thanks to fluffy for the solution:
this.startFarTrigger = function (entityID) {
// Do stuff
};

this.startNearGrab = function (entityID) {
    // Do stuff
};

this.clickDownOnEntity = function (entityID, mouseEvent) {
    if (mouseEvent.isLeftButton) {
        // Do stuff
    }
};

Maybe these methods can be added to the online documentation :slight_smile:


#3

Must test this with my simple touch and teleport example… :slight_smile: