0
\$\begingroup\$

I am working with Unity and C#, but my Problem is a more general programming problem. I am trying to keep things easy, but still make them global access able and easy to modify.

So I have a Character_Model_Selection class, in which You can scroll from the right to the left with shifting for example to your desired model and then select it . An Id keeps track of which model is infront of the User on select. If He selects it, I compare that Id With an Integer and If it is equal to it, I pass it a string of the actual "hero" name . Before I used a singleton to create an default instance, modify the Name and then access it in the Main screen, but since I have multiply Players with different spawns singletons doesn't really make sense anymore.

Question: What design Pattern or technique could I use to have a Base class of a Player hero, which has some default properties, like health and pushforce. With I can create multiply instances of but make it global access able and modify the default properties on select.

\$\endgroup\$
0
\$\begingroup\$

The pattern you are looking for is called Inheritance.

Stop using Singletons. Create a base class with default properties. Then create derived classes off of your base class, to create your separate entities.

https://en.wikipedia.org/wiki/Inheritance_%28object-oriented_programming%29

Post code samples if you want more help.

\$\endgroup\$
0

Not the answer you're looking for? Browse other questions tagged or ask your own question.