1
\$\begingroup\$

I'm trying to understand the concept of game controllers and what all they're used for in different types of games. Are they mainly to control how the game operates? For instance, if I had an RPG that had a questing system, would it be the game controller that manages that? So what all should I consider when building a game controller? Is it everything that doesn't involve user input? Can anyone explain this to me, or at least point me in the direction to find this information?

To clarify, I'm not talking about physical game controllers, I'm talking about the game manager script you add to your game attached as a game object.

\$\endgroup\$
  • \$\begingroup\$ If you're talking about gamepads/Joysticks, they are no different than keyboard/mouse, as in you map actions to buttons/keys. I'm a bit confused at your question. Are you talking about Systems/Subsystems/managers? \$\endgroup\$ – Sidar Jul 26 '17 at 15:28
  • \$\begingroup\$ Have you looked at Game Controllers on Unity's website? They've got a couple tutorials that involve using a Game Controller. \$\endgroup\$ – n_plum Jul 26 '17 at 15:29
  • \$\begingroup\$ @Sidar Sorry, yes, I mean the managing script. I've updated the title and details to clarify this. \$\endgroup\$ – Robert Jul 26 '17 at 15:31
  • \$\begingroup\$ I don't think this is a question that has a concise correct answer. Manager scripts like these don't necessarily follow a common template or recipe — they're a response to the specific features they're trying to support. I think you'll get much better answers if you edit this to focus on a specific feature you're trying to write a manager for, like the quest system you mention. What needs does this quest manager have to fulfill, how have you gone about architecting it so far, and what specific problems do you want to solve or improve? \$\endgroup\$ – DMGregory Jul 26 '17 at 16:15
4
\$\begingroup\$

For instance, if I had an RPG that had a questing system, would it be the game controller that manages that?

It would not be the game controller, it would be a game controller.

A controller is a class which notices when it's time to do something and then makes that happen. In the context of game development, each controller is usually responsible for one game feature. This is called the single responsibility principle. If you try to squeeze every single feature of your game into one controller, you will end up with a huge god object. In a very simple game you might get away with that, which is why many of the basic Unity tutorials follow that pattern. But if your game is more complex, then your controller-class will become so huge that it will be completely unmaintainable.

The controller for your quest system would be the QuestController. Its Update-method would check if the success-condition or failure-condition of any quest is met and when that is the case trigger whatever is supposed to happen in that situation.

When you delve deeper into Unity, you will encounter some controllers which are provided by the Unity engine itself and dedicated to specific engine features, like the AnimationController or the CharacterController .

Is it everything that doesn't involve user input?

User-input would actually also be handled by a controller, which most people usually name InputController or PlayerController.

\$\endgroup\$
  • 2
    \$\begingroup\$ I've also seen managers that operate on a notification model. For example, any time the player does something that could complete a quest (collect an item, defeat an enemy...) a message reports that to the quest manager, which can then decide whether that action does complete the current quest (or progress a milestone within it...) That saves the manager from polling every frame for quest updates, when quest-completing actions are often much more rare than that. \$\endgroup\$ – DMGregory Jul 26 '17 at 16:21
  • 2
    \$\begingroup\$ @DMGregory Do you agree that "Manager" and "Controller" are usually synonyms for basically the same thing? Or do you believe that there is a meaningful distinction between the two? \$\endgroup\$ – Philipp Jul 26 '17 at 16:23
  • 2
    \$\begingroup\$ Good question! I haven't seen a well-established taxonomy that draws a clear line between the two, but like so much terminology in gamedev, that might vary between parts of our community. In my experience they both refer to an object or static class with no physical representation in the game world that's "in charge" of some long-lived functionality that multiple other behaviours might want to interact with, giving them a central point of reference and authority for that feature. Any distinction I've seen might be one of emphasis, with controllers more "hands-on" and managers more "background' \$\endgroup\$ – DMGregory Jul 26 '17 at 16:29
  • \$\begingroup\$ I'm am but a fledgling indie dev, but I have to agree with @DMGregory - this is how I've basically categorized Controller and Manager as well. For me, instead of "hands-on" vs. "background" I see them as "active" vs. "passive", if only because I consider any managers or controllers to be background (not user-facing). But yeah, I make a very similar distinction between them. A controller is actively polling for changes (like an inputController). A manager is told about a change (like a QuestManager or AudioManager). Definitely more discussion related, but I'd love to have this conversation \$\endgroup\$ – Jesse Williams Jul 26 '17 at 19:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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