Detecting User Input

Prerequisite: Read Overview of the MVC Pattern

A game engine can detect user inputs from several sources. For example, it can detect inputs from a physical game-controller, keyboards, mouse and virtual mediums such as buttons. All of these inputs are directed to the game engine through the Controller Component of the MVC.


When a user-input is detected, the Controller Component informs the Model Component, and it provides detailed information about the input. Such as which button the user pressed, or the direction of the joystick.


Who decides what to do you with this information?

The decision lies with the game developer. The game developer implements the Game-Logic in the Model Component and determines what to do with a received user-input. For example, if button A is pressed, then a character is rotated. If the joystick is moved, then a character walks, etc.

Controlling a character using the Untold Engine

A user interacts with a game character through the Controller and Model Components.

The Controller Component detects the user input and provides this information to the Model Component. In turn, the Model Component interacts with the game character.


However, this interaction can't occur until the View Component provides the Model Component a pointer to the game character. Recall that the View Component has a list of all characters present in a game. The Model Component is not aware of this list.

Thus, the process to control a character with a controller is as follows:

(In Model Component)

  1. Get a pointer to the game character from the View Component
  2. Process messages from the Controller Component
  3. Interact with the game character

Let's assume that you want to move the 3D character with a game controller.


The first step is to communicate with the View Component and ask for the astronaut pointer.


The next step is to process the messages from the Controller Component and determine which button was pressed.


Finally, depending on the button pressed, we interact with the 3D character.