I just published a video where I describe how to start modelling and developing a sport game, specifically football (soccer) in my case:
In the following notes some motivation for the work and references from the video.
What am I trying to do?
I am creating a game on football (not American Football), called Football Drama: this game is supposedly the story of the coach in the context of a Football Manager like game. The latest version of Football Manager for smartphones has a cool game play:
One of the first thing I did in Unity is search for a plugin that would handle the match play part. Given the number of plugins available in the Asset Store and the popularity of football, I was pretty sure that my only problem would be picking the best plugin. Wrong.
I didn’t want to do this
The only decent looking component I found is Soccer Project by “Astute Games”, which is ok but actually does nothing useful in my perspective, as it provides passive 3D models of players and little more.
The are simply no plugins covering modelling, movement and AI for football games in the Asset Store.
Maybe because “The barrier of entry on making a decent team sports game is really high.”, as they say in one of the few discussion of the theme indie & sports available online.
The Simple Soccer example
In chapter 4 of the book Programming Game AI by Example the author provides a nice implementation of a simple soccer game.
I’ve downloaded the Java sources and made the sample run in my IDE.
Here are some of the Java classes of this example:
Movements are regulated by physics:
Complete Java source code is here.
Not what I want for a sport game
This material is useful but what it is modelling is not football. seems more snooker to me . I want a simple grid with squares as players and a state handling framework, where the (hierarchical) state machine can easily be extended. Movement is not determined by physics – the right metaphor is not snooker.
If you actually watch a football game, its a highly fractioned game of control and tactics, my reference for this development has been Cameroon vs. England (World Cup 1990):
Physics plays a role on long shots, but I will model that using tweening (the wonderful DOTween library by Daniele Giardini). I will call the model I need Football Grid.
Football Grid: The model
The example is also using heavily inheritance to model all aspects of play. I instead will be happily mixing inheritance and composition, reducing inheritance to a minimum and modelling state with classes only when strictly necessary. A great book to learn about basic game programming patterns, if you are new to the topic is Game Programming Patterns.
The three states of game play: paused, preparing play, in play: this is simply an enum.
I used object hierarchy and modelling of states with class instances only when it is strictly useful, so e.g. in the case of a player state.
Here are the classes of my model:
Curve ball effects
To get these effects you can simply tween (I use DOTween) the ball differently along the X and Y axis:
Follow me on Twitter – I study game design, development (2D), applied games, and I post about progress on Football Drama.
Unity components used
Game Logic Grids http://gamelogic.co.za/grids/
“Association football 4-4-2 formation” by MaxDZ8, based on work from Mario Ortegon – self-made, original file from Mario Ortegon. Licensed under CC BY 2.5 via Wikimedia Commons – http://commons.wikimedia.org/wiki/File:Association_football_4-4-2_formation.svg#/media/File:Association_football_4-4-2_formation.svg
“Association football 4-3-3 formation” by Threner. Licensed under CC BY-SA 3.0 via Wikimedia Commons – http://commons.wikimedia.org/wiki/File:Association_football_4-3-3_formation.svg#/media/File:Association_football_4-3-3_formation.svg
The post Making a sport game in Unity: model & prototype appeared first on Design a Game.