I did some quite complex objects and vehicles and want to have them in team colors in game. But not the default colors, but some that fit more to the scenario. And I do not want to change the complete model to team colors, only certain parts.
I could do this per script and per part. Is there a way to change a complete material template for all objects in the scene depending on the team? Or can I change somehow all parts in a folder or in a group or merged model? Or do you have a quite better idea what I can do?
I have also used a script to tint merged models based on object names, here is an example (so this is client side with the merged model as the first child of the script):
local mergedModel = script:FindChildByName("MergedModel")
local childObjects = mergedModel:GetChildren()
local baseColor = Color.New(0.910, 0.670, 0.200)
local darkColor = Color.New(baseColor.r * 0.5, baseColor.g * 0.5, baseColor.b * 0.5)
local lightColor = Color.New(baseColor.r * 1.5, baseColor.g * 1.5, baseColor.b * 1.5)
for _, object in ipairs(childObjects) do
if object.name == "VaryColor" then
object:SetColor(baseColor])
elseif object.name == "DarkColor" then
object:SetColor(darkColor)
elseif object.name == "LightColor" then
object:SetColor(lightColor)
end
end
Sorry, I've just hacked this out of my script and tried to simplify it, hopefully it still works, or at least shows an option for you.
If you want to color material Trims etc. I guess you can also do that by grabbing the separate material slots using some of the code in that documentation I linked you to.