Jump to content

  • Log In with Google      Sign In   
  • Create Account


#ActualDan Violet Sagmiller

Posted 21 February 2013 - 07:55 AM

You can think about your game state Update function as Controller.

 

Update functions, and components in general in most cases.  

 

 

Does anyone has an example on how MVC pattern will work in a videogame? particulary on Unity

 

The MVC pattern is good for games, but I tend to find a stronger blur between Model and Controller.  Separating the code is good, and I'll do that in most things I do, but I'm not going to let MVC stand as a permanent requirement, when sometimes it just makes more sense to have some data and logic floating intermingled for performance needs.  I.e. if you keep the MVC model, would typically require an impact controller to loop through all the game objects for collisions with particular objects.  But then you also have Momentum controllers, AI controllers, gravity controllers, etc...  Each one needing to loop through your gameobject list to make changes.  Or, you could blur the Model-Controller, and add an update function to the game object that takes care of all the same logic, but this structure requires only one loop through the game objects.  

 

MVC is good, but games some times need more efficiency.  

 

(I should include that I certainly think MVC is possible in game development, and that it can be done elegantly in many situations.  For a web app or forms app, I will typically impliment MVC, MVVM or a similar model.  For games, while while still defaulting to MVC, I just don't lock myself to it.  I don't step away from it without good reason either)


#1Dan Violet Sagmiller

Posted 21 February 2013 - 07:41 AM

You can think about your game state Update function as Controller.

 

Update functions, and components in general in most cases.  

 

Does anyone has an example on how MVC pattern will work in a videogame? particulary on Unity

 

The MVC pattern is good for games, but I tend to find a stronger blur between Model and Controller.  Separating the code is good, and I'll do that in most things I do, but I'm not going to let MVC stand as a permanent requirement, when sometimes it just makes more sense to have some data and logic floating intermingled for performance needs.  I.e. if you keep the MVC model, would typically require an impact controller to loop through all the game objects for collisions with particular objects.  But then you also have Momentum controllers, AI controllers, gravity controllers, etc...  Each one needing to loop through your gameobject list to make changes.  Or, you could blur the Model-Controller, and add an update function to the game object that takes care of all the same logic, but this structure requires only one loop through the game objects.  

 

MVC is good, but games some times need more efficiency.  


PARTNERS