[bug?!?]Problem with StarterGameUtility Material replacement and parameter set.

  1. if I don’t override the material on the mesh the editor crashes.

  2. it shows in console these kind of errors.

StarterGameGem::StarterGameUtility::SetShaderFloat couldn’t find a material on healthcanister (18002375458703873393)

StarterGameGem::StarterGameUtility::SetShaderFloat couldn’t find a material on healthcanister (18002375462998840689)

This issue looks to be related to the issue in Starter Game where bullet trail doesn’t hide itself in some runs.

my test script is


	mattest = {
Properties = {
delta = {default = 1},
},
OnActivate = function(self)
self.tickBusHandler = TickBus.Connect(self)
StarterGameUtility.ReplaceMaterialWithClone(self.entityId)
self.coso = 0;
end,
OnDeactivate = function(self)
self.tickBusHandler:Disconnect()
StarterGameUtility.RestoreOriginalMaterial(self.entityId)
end,
OnTick = function(self, deltatime, timePoint)
local two_pi = math.pi * 2
self.coso = (self.coso + self.Properties.delta * deltatime) % two_pi
StarterGameUtility.SetShaderFloat(self.entityId,"DissolvePercentage",math.sin(self.coso))
--if self.coso > 1 then self.coso = 0 end
end,
}
return mattest

It works but it didn’t clone at all the material or it get overrided from the override(it crashes elsewhere) so every instance get the same animation even if I change the delta parameter so they are all actually sharing the same material and not the clone.

Can someone enlight me on the proper use without crashes?

The material don’t get back to original as it never change to anything else so you can have object dissolved while editing the game as it change the original material.

Interesting - let me see if I can dig up some answers on this topic :slight_smile:

looks like set material parameter has a problem somehow related to material groups as when I override the material it works only it is a plain material , if I replace it with a material group it still doesn’t work.

The original material I try to clone is indeed a material group as almost every kind of imported mesh.

So I tried to export a designer mesh to .cgf with a plain material and it works(it still doesn’t clone the material so every other object using the material get animated).

So clone doesn’t even work with plain materials.

Thanks for the update @Gamely! I’ve appended this observation in our notes for further exploration :slight_smile: