tipforeveryone Posted September 11, 2016 Share Posted September 11, 2016 Hello, I have a militarybag.mdl and want to apply 2 different camoflage materials on it I put 2 instances of that bag into my scene then attach a lua file to one of them, here is my script: function Script:Start() local mat = Material:Load("testmaterial.mat") self.entity:SetMaterial(mat) end The result is both of bags change material. Does it mean I can not change material for each of bag instance ? Is there anyway to do my need ? Quote Link to comment Share on other sites More sharing options...
Thirsty Panther Posted September 11, 2016 Share Posted September 11, 2016 An instance of an object is a copy so I guess if you change one it will change the other. Quote Link to comment Share on other sites More sharing options...
tipforeveryone Posted September 11, 2016 Author Share Posted September 11, 2016 I put them in scene by dragging from asset window And the same thing happens if I use: Local model = Model:Load() Local mat = Material:Load() Model:SetMaterial(mat) Quote Link to comment Share on other sites More sharing options...
martyj Posted September 11, 2016 Share Posted September 11, 2016 You have to call Model::Load with additional parameters. Model::Load(path, , Asset::Unmanaged); This will allow you to have a unique instance of each model. Only use this for models that you wish to have a custom skin for. Otherwise you're just wasting resources. Quote Link to comment Share on other sites More sharing options...
shadmar Posted September 11, 2016 Share Posted September 11, 2016 I think you have to use Asset.CreateNew as flag, not Asset.Unmanaged (which is the default) Quote HP Omen - 16GB - i7 - Nvidia GTX 1060 6GB Link to comment Share on other sites More sharing options...
martyj Posted September 11, 2016 Share Posted September 11, 2016 @Shadmar, Assets::Unmanaged works for me. 1 Quote Link to comment Share on other sites More sharing options...
macklebee Posted September 11, 2016 Share Posted September 11, 2016 http://www.leadwerks.com/werkspace/topic/14513-unique-model-material/#entry99202 1 Quote Win7 64bit / Intel i7-2600 CPU @ 3.9 GHz / 16 GB DDR3 / NVIDIA GeForce GTX 590 LE / 3DWS / BMX / Hexagon macklebee's channel Link to comment Share on other sites More sharing options...
tipforeveryone Posted September 11, 2016 Author Share Posted September 11, 2016 Thank you, Asset.Unmanaged works Quote Link to comment Share on other sites More sharing options...
shadmar Posted September 11, 2016 Share Posted September 11, 2016 @Shadmar, Assets::Unmanaged works for me. I agree Quote HP Omen - 16GB - i7 - Nvidia GTX 1060 6GB Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.