Hi, I’m currently working on enabling random entities, I just want to add a function that replaces the material on every entity being enabled, is this possible? thanks in advance. PlayCanvas | HTML5 Game Engine
There multiple ways to do that and it depends on how you are structuring your scene and code.
For example one way to replace the material on a single mesh instance render component:
const newMaterial = this.app.assets.find('My Material', 'material');
this.entity.render.meshInstances[0].material = newMaterial.resource;
1 Like