I want to change color of individual model in my game. But when I use
effect.DiffuseColor = newColor
then all of models which were loaded from same model file change color too.
How can I do ?
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It only takes a minute to sign up.
Sign up to join this communityyou are changing the Diffusecolor in the same effect.
there is no easy way to clone a model
so the answer is before draw set the color properly for each model
// Draw method
foreach (ModelMesh mesh in m.Meshes)
{
foreach (BasicEffect effect in mesh.Effects)
{
effect.DiffuseColor = newColor;
}
mesh.Draw();
}