1
\$\begingroup\$

I found this post for designing a camera system the post mentions having a manager where you could register and set different cameras such as debug, player, script, etc and I kind of like this approach, but I have a few questions when it comes to designing a manager type class.

Would it be beneficial to have getters/setters for a specific object in the manager? For my situation I ran into a problem where my player object needs the position of the player camera so that it can rotate its model in the direction the camera is pointing so should the manager have GetPositionOfCurrentCamera() or GetPosition("ID_Of_Camera") or would it be better to just have GetRegisteredCamera("ID_Of_Camera") and then get whatever I need from the camera itself.

Note: I think I found my answer to this having a getter to the object by it's id is the better option. Going to leave it here just in case someone has other tips/suggestions.

Lastly, when it comes to making the manager accessible I know a few patterns such as singleton, service locator, and dependency injection(?) are any of these patterns fine or is there one better suited/more common?

\$\endgroup\$
1
  • \$\begingroup\$ I love to use singleton in my own projects but currently I'm working on a team project where we use zenject (dependency injection), it looks good but requires additional knowledge to set up everything correctly, and for me it is not beginner friendly, and you need to integrate the additional asset to your project. So if you have a wish to learn some library you can do it. If not - you can use singletone it is the simplest way. \$\endgroup\$
    – Bogdan
    Commented Jan 13 at 21:48

0

You must log in to answer this question.

Browse other questions tagged .