I’ve used this instead and works fine, but this is prone to more user error, since I have to make sure everything is tagged correctly. It would be nice to just check if it has the script attached or not.
result.entity.tags.has('changeMat')
//instead of
result.entity.script.has('ChangeMaterial')
Imagine I have an entity with a script component. I add a new script called my-script.js with initially looks like this:
var MyScript = pc.createScript('myScript');
// initialize code called once per entity
MyScript.prototype.initialize = function() {
};
// update code called every frame
MyScript.prototype.update = function(dt) {
};
Then, I can add a second script called check-for-script.js:
var CheckForScript = pc.createScript('checkForScript');
// initialize code called once per entity
CheckForScript.prototype.initialize = function() {
if (this.entity.script.myScript) {
console.log("Yep. It's got the script!");
}
};