[SOLVED] Changing the diffuse color of a material

        let sphere = pc.app.root.findByName('Toplar').findByName('Sphere');
        sphere.model.meshInstances[0].material.diffuseMapTint = new pc.Color(1, 0, 0, 1); 

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); 

Check the standard material docs page, it has a number of code examples:

1 Like

Thank you

1 Like