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
setMaterialOverrides does not work on rendered object
Re: setMaterialOverrides does not work on rendered object
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.
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.
Grimrock 1 dungeon
Grimrock 2 resources
I no longer answer scripting questions in private messages. Please ask in a forum topic or this Discord server.
Grimrock 2 resources
I no longer answer scripting questions in private messages. Please ask in a forum topic or this Discord server.
Re: setMaterialOverrides does not work on rendered object
Ninja'd... But you don't even need the parenthesis; it's a table.
*However... What works in the console, does not seem to work in a script_entity. Delayed Call() fixes this.

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.

Re: setMaterialOverrides does not work on rendered object
Minmay, I think you are right! I will confirm. Good catch.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.