We got our first concept art today from Ivan, an artist we are working with on Wendy’s Weddings, a wedding themed casual title. He does some nice work as you can see with his first pass at some concept on some of Wendy and her little sister Molly.
You can take a look at more of his stuff at synergylab.com.my. We are still working on the characters so the are by no means final. Running comments on Wendy being a little too bossy looking have been noted and we are working on making her more fashionable and friendly.
The game revolves around helping Wendy build her Wedding Business and is being developed with assistance from Pretty In White. We have only been developing the game for about 2 weeks in total, but the basic gameplay is there and we are finishing off the Game Design documents before moving fully into production. Jordan from Zombie Gecko is helping with the Game Design. Still pretty early but the design and gameplay look exciting and we talk more about it in the future.
Our target is primarily on iOS and Mac as we are using the Cocos2D game framework. I have written in the past how I built a ‘component’ based system around this framework.
I know my 3 sisters and 2 nieces will be so happy I am finally making a game they will like to play. Maybe I can sneak in alien secret character;P
This post is a follow up to my first one which gives you some concepts on working with networking. In this post, I will cover getting an a client/server connection going which is the first thing you have to do in building a multiplayer game. Your first point of reference is to make sure you are familiar with the Unity3D Network class which provide most the functionality you need to manage an initial network session.
I would like to cover some Unity3D specific topics on how networking is handled. Unity uses a Network View Component that is attached to every game object who’s state you want to synchronize with. It also allows you to send messages directly to those objects because each one is issued a network ID. The following picture should make things clearer:
Let’s also cover the ‘responsibilities’ in networking between the Client and Server.
- The Server’s primary responsibility is managing the network session and propagating/validating state changes to connecting clients. It is also responsible for control of non-player game objects(i.e. enemies) by creating them when needed, running the AI routines which tell them to move. There are 2 modes that the server can operate under, authoritative and non. Authoritative servers have more work because they have to validate state changes from the client rather than merely passing it along to other clients. This is usually a slower way to operate as each move, action needs to be checked. If found to be invalid then the client that sent this original state changes need to be ‘brought in line’ with the way the server is thinking. A non-authoritative server on the other hand is more of a delivery person who simply relies information over to connected clients
- The Client is responsible for the view of the world a player sees and for receiving input and forwarding it over to the server. In a non-authoritative mode, the client can also process game logic (i.e. decrease health, move the player, move other objects) and these are sent to the server to be relayed to the other clients.
The first step in getting a network session up and running is initialize a server, which should be done when a level in the game loads up. This is done using the method on the Network class called “IntializeServer“. The first parameter is the number of connections to take. The second the listening port for the server, which is used by the clients to determine which application to connect on the server (as a server may be running multiple network applications). The last parameter if Network Address Translation should be used or not. All these except for the number of connections should be eventually made user configurable when you are writing your game.
Once the server is running, clients can connect using the Network.Connect method. The most important parameters for now is the ip address of the server and the remote port(which was the listening port specified earlier when the server was initialized).
That’s pretty much all there is for setting up a session. Be sure to check the Network class for more information on how to handle disconnects and network failures.
I have set about learning about networking on Unity3D in order to implement multiplayer support for Zombie Gecko’s Comrade In Arms. I have a fair amount of experience with networking, having first cut my teeth writing real-time transactional system allowing Unix hosts to update banking details to a IBM Mainframe using XNA, then working on early Internet credit card authorizations system and finally developing the server/networking code for Fung Wan Online MMOG. Well enough about me ;P
Unity3D uses RakNet for standard networking and who ever is implementing things will have a lot of plumbing to take care of inorder to get things working. Unity uses a “Networking View” component which must be attached to all objects which in turn Network State Synchronization and Remote Procedure Calls(RPC’s) to occur. You can set specific spatial components to be observed by a network view but usually you will implement a script that will pre/post process network information sent. This was something I missed when I first started out tinkering with networking on Unity
Let’s go back a bit and talk about the 2 different methods of communicating in Unity:
- State synchronization - this is basically a method of setting the network view to observe a script component that processes changes in states that can be sent to the server which in turn are transmitted to all listening clients.
- Remote Procedure Calls – This is a common enough networking concept that allows you send invoke functions on the server or all clients with parameters being passed.
You can do some additional reading on networking by looking up the following resource:
- Unity documentation
- iPhone Multiplayer demo – still works and you can substitute a web view for an iphone
- Unity Networking Example – Still works on Unity 3.3
- M2H networking tutorials – It cost money now, but there was a simple network tutorial that is floating around the network.
In a follow up posting, I will go through making connections,extrapolation,interpolation and hooking RigidBody objects.
Although an component system is the basis for most modern game engines and considered as the better(if not the best) way to put together a game. One of the biggest drawbacks is that when you create an architecture that is modular and loosely coupled, you introduce performance overheads.
On PC and other higher end devices, the tradeoff is smaller in exchange for elegancy of design and implementation. On the iPhone, especially older ones you have to to be care about how to implement things. The most common discussion on most game dev sites on the iphone is to watch your draw calls. On older 3G devices, 20-30 is a bandied around number…well that obviously and how many polys you are using plus if your code is running native or script…where is all this leading too….Ah yes the component system I was building on top of Cocos2D.
Here are some of potential performance overheads I ran into while implement it:
- One of design limitation you have to work on cocos2d uses a SpriteBatchNode to allow ‘sprites’ using the same texture to be drawn in a single draw. In a component system, everything is based around composition which means there is a lightweight ‘entity’ class with ‘components’ attached to it. So 1 entity = 1 draw call at the very minimum. With the older 3G devices, you are restricted to 25-30 draw calls (as a rule of thumb that is float on the Internet).
- Sharing of properties between components. While I have allowed the position property to be stored on the entity itself, other functionality specific properties aren’t. In order to do so you will have to either incur a dictionary look up (i.e. component foo = entity.lookupComponentByName(Bar)). Or you could directly link it up be assigning it to a pointer. Doing that however breaks a design principle of trying to make components loosely coupled for modularity
- Inter component communications. Besides directly looking up a component, a better way to talk to between components is to use ‘events’. For my component system, I built a addEventListerner,dispatchEventListener system similar to what Flash has. Like all events though everything is unidirectional and has a limited data payload of a single object.
In conclusion, I think for most of the newer games going with component system makes sense because once you get started you will be amazed at how everything clicks into place. If you are writing some more performance intensive, you will find components losing some of its appeal.