let sphere = pc.app.root.findByName('Toplar').findByName('Sphere');
sphere.model.meshInstances[0].material.diffuseMapTint = new pc.Color(1, 0, 0, 1);
sphere.model.meshInstances[0].material.update();
I want to change the ‘player’ ball’s color on collision with another ball. Upon collision the ball should check for the other balls color and then automatically adjust to the color of the other ball?
Hi @Ozden_Delibas,
diffuseMapTint
is a boolean that means it can take either true or false as values. It’s used to apply a color tint on top of a texture map.
If you don’t use a texture map, you don’t need to bother with it. To change the diffuse color just do this:
sphere.model.meshInstances[0].material.diffuse.set(1, 0, 0);
sphere.model.meshInstances[0].material.update();
Check the standard material docs page, it has a number of code examples:
https://developer.playcanvas.com/en/api/pc.StandardMaterial.html
1 Like