Page 1 of 1

setMaterialOverrides does not work on rendered object

Posted: Tue Oct 27, 2015 3:29 am
by MrChoke
I have been calling setMaterialOverrides() in my code for quite some time with no issues. But I guess it is not until now that I want to call it on an object that has already been rendered. Now I call it and it doesn't work. Is there some way I can force the game re-render an object? I tried disable/enable on the model component. That did not work.

Thanks

Re: setMaterialOverrides does not work on rendered object

Posted: Tue Oct 27, 2015 9:30 am
by minmay
Dynamic setMaterialOverrides() works fine for me. Are you sure the table you're passing is naming the right materials, accounting for previous overrides?
For example, if you've previously done setMaterialOverrides({material1="material2"}) then setMaterialOverrides({material1="material3"}) won't do anything; you need to use setMaterialOverrides({material2="material3"}) because you changed material1 to material2.

Re: setMaterialOverrides does not work on rendered object

Posted: Tue Oct 27, 2015 9:53 am
by Isaac
Ninja'd... But you don't even need the parenthesis; it's a table.

Code: Select all

function override() forest_ogre_1.model:setMaterialOverrides{forest_ogre_club = "healing_crystal_black1"} end

delayedCall(self.go.id, 0, "override")


*However... What works in the console, does not seem to work in a script_entity. Delayed Call() fixes this.

Image

Re: setMaterialOverrides does not work on rendered object

Posted: Tue Oct 27, 2015 1:13 pm
by MrChoke
minmay wrote:Dynamic setMaterialOverrides() works fine for me. Are you sure the table you're passing is naming the right materials, accounting for previous overrides?
For example, if you've previously done setMaterialOverrides({material1="material2"}) then setMaterialOverrides({material1="material3"}) won't do anything; you need to use setMaterialOverrides({material2="material3"}) because you changed material1 to material2.
Minmay, I think you are right! I will confirm. Good catch.