Is there a way to get the default materials for a mesh in a class?

I would like to be able to click on any object to change it’s material, then click on it again to reset it to it’s default material. Can this be done?

My current idea for how this could be done would be to get the base class of the object and read it from there, since the base class should contain that default information, but I cannot figure out a way to actually do this.

I did figure out how to get the default materials of the mesh generally speaking. (excuse the ungodly spaghetti…)

But still not the defaults as defined by the class, I’m gonna accept this as a solution for now but… If anyone knows how to get the class default materials for a mesh instead, then I will mark that as a solution instead.

Edit: Here’s a better way which gets the material of the object it clicked on as is and returns it when clicked again.

But due to weird behavior that was exhibited when I tried to remove an item from the array aftersetting it (it seemed like removing individual items didn’t always work, only ‘clering’ the array reliably worked, and even then there was some very odd behavior where even if the array had been cleared some of the items that had been on it before it was cleared could still be ‘fetched’ by the code, it was super bizarre) so instead it just clears the array when the object map is emptied.

The downside here is that the array can grow infinitely big which is certainly not ideal.

you’d really just want an interface, just tell the actor its clicked an let it update its own materials as suits it

No, not every object will have a dedicated class blueprint (and if they did I wouldn’t want to implement this for every single object in the game that needs to support this function, that’d be madness), if i was gonna do it that way (which to be fair is starting to look like the way it’s gonna have to be done) i’d probably use datatables instead.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.