Quick Question about Singletons

Kind of an odd question to ask… So I’ve made an Inventory, Equipment, Hotbar, other tabs(stats/skills/abilities). Most are being called by Singletons. Not sure if that is a horrible thing to do or not but it seemed easy enough to implement with…

I was really wondering if I was going to later make this MultiPlayer capable would the Singletons work the same? Like would it be client side calling that Singleton… So other people aren’t calling everyone else Inventory, Hotbar, etc…

I’m really wondering because I’m thinking of going through it and making it more customizable so other people could use it.

Thanks for taking the time

Eiznek, from everything I have come to learn and understand of Unity so far, the singleton pattern is not where you want to be looking to go. I myself came from such engines where using a singleton was not the worst thing in the world, but with Unity it really takes hold of the component based design patterns.

I can easily see where you would think this to be a decent route to head down, but I might suggest using a messenger system to send information from component to component, and in doing such you will save yourself the hassel of having to have each class know of each other, even if in no other way then a reference to a singleton object; in the end I feel that this could potentially save you quite a bit of headache in the long run.

For the multiplayer aspect, the messenger system would even work, both client side and server side depending on the needs of an authoritative server or not; messages would/could still be passed in some fashion or another.

Let me know if you are still in need of further explanation or even or code sample, and I may be able to provide you with one in fairly short order. In the mean time, good luck with your endeavors!