Synchronization in multiplayer networked game? - iphone

Recently I have been working on a multiplayer networking app. I had successfully implemented the client server model using Bonjour services and NSStream objects. The two way communication has been done successfully.
The problem I'm facing is: the two devices running the app are connected via local wifi. There is a latency problem while sending the messages from client to server and vice versa.
Describing in brief:
It's a car racing game with at most two players.
One server and other client.
When client press the buttons a particular message is sent to the server telling which key or button was pressed. Then the server responds accordingly and make changes on the client's car on the server itself. These changes are not always the same. There is always a difference between the actual location of the car on the client's screen and that in the server screen.
Any ideas?

Welcome to the world of networking. :)
These are the classic difficulties with game networking programming. There's a lot of different techniques to overcome these issues.
This blog has great info on the subject and will probably help you out.
http://gafferongames.com/networking-for-game-programmers/
You may be specifically interested in this article:
http://www.gafferongames.com/networking-for-game-programmers/what-every-programmer-needs-to-know-about-game-networking
Good luck!

Related

Unity Matchmaking how it works / dedicated Server

I create a 2D ffa multiplayer game for android with Unity/Netcode. Now my question is how i could set up a dedicated Server with matchmaking. Do i have one Unity instance who is waiting for requests. And when it received enaugh question. It creates a new Unity instance as 'real' server and send pack the port. But we only have around 64k ports. So i would realy intrested how at the end, the server is started. Or is there only one Unity instance with multiple game Scences? I know unity has a hosting/matchmaking service. But i have not much money. And i want run specific code on Server for other stuff in the game for example database and a Trading system. Maybe somebody has an idea.
Thanks for your time.Lyksel
I was thinking of openmatch but i didn't find out if i can use it on a dedicated server.

What would be the software architecture of a videogame?

I'm developing a videogame under Unity. I've been asked to describe the software architecture of my project. My videogame won't be using databases nor it will be connected to a server, it is a platform adventure kind of game with one player.
I have heard of other architectures like client-server, peer-to-peer, service-oriented, but can't find the one that truly fits a videogame.
Without further informations nobody can help you. You need to tell us more about your game.
But I guess you program a multiplayer.
Client-Server
In short every player (client) will connect to a server and this server will mostly do all the work what happens in your game.
Peer-to-Peer (P2P)
Here, there will be only one host (server) and every client will connect on it. Because of this, there will be some problems if the host is far away from the clients and more. Basically if you are the host it is much easier to cheat because you are the server.

How can I implement multiplayer in my iphone game?

I want to create a playstation home style multiplayer game for iphone. How can I implement multiplayer in my project? Also, how can I give players a chance to chat? How can I let them create their own avatars to interact? I am a one man developer, with no access to servers. Maybe I can use iPhone game centre???
If you're looking for some kind of platform to build on, there is a product called SmartFoxServer:
http://www.smartfoxserver.com/
I have not used it, but it claims to provide a client API for native Obj-C or Unity3D. It allows for chat features.
If you want to roll your own, I recommend getting started with NodeJS:
http://nodejs.org/
GameCenter does not provide any kind of backend for multiplayer networking, at least not in the way you are implying. If you intend to build a networked multiplayer game over the internet, you most likely need some kind of backend.
Slicehost is a good way of getting a server like NodeJS running quickly and cheaply:
http://www.slicehost.com/
Don't forget that GameKit in iOS allows multiple devices to find each other locally (via Bluetooth or local Wifi) and create sessions. This might be a good starting point for your game. Here's some info on GameKit:
http://developer.apple.com/library/ios/#documentation/NetworkingInternet/Conceptual/GameKit_Guide/Introduction/Introduction.html
I think this would usually be done with webservice interaction against a server. You may be able to develop a webservice and pay a small fee to have it hosted by a web provider, or to use your own machine as (an unreliable) server while proving the concept.
Or you could just use Nextpeer - http://www.nextpeer.com
It makes adding online tournaments to your game real simple.
You can look at Gamooga (http://www.gamooga.com/).
Its a realtime communication platform for multiplayer games so you dont need to worry about building and deploying your own multiplayer servers. You can upload your own server side scripts onto Gamooga's cluster which receive and process your clients' messages. You can use Gamooga's iOS API with in your app to send messages from the client side to your server side scripts. You can download the SDK and look at the demos to start off.
There is a free plan of Gamooga platform too that you can make use of to start with.
Disclosure: I am founder of Gamooga, replying only since its relevant to the question.

peer-to-peer multiplayer game with xmpp

I'm fairly new to multiplayer games. I have made a few for my own fun, but nothing profound.
Anyway, I want to make a game that is very cross-platform. The clients would be connected with their facebook accounts on the devices I release the game for (most likely computers (via flash), iPhone, and android). I am a solo developer on a shoestring budget (actually more like no budget). So, I want to make the game with a peer-to-peer connection. I would like to avoid using a client/server setup because of the cost to maintain a server. The problem I am running into is there is no way to connect peers over the internet, and the game is not meant to be played over a local wifi.
So, I have an idea. Can I use facebook's built in xmpp chat to send the game's multiplayer communication over the internet? I have head of xmpp being used for multiplayer games before. Does anyone have any other ideas? I understand that xmpp can be connected peer-to-peer, but can it be done over the internet somehow. I don't want the users to have to mess with router settings to play.
Thanks for your help!
The main problem in P2P systems are NATs and firewalls. Firewalls can be locally opened, NATs cannot in 99% of the cases. In the IPv6 world there will be no NATs, so P2P will be free for all.
Now you want to use Facebook's XMPP APIs for P2P multiplayer. Well... Facebook's XMPP is practically client/server because of the above reason. All Facebook's APIs do is to hide the transport layer to applications, meaning that you can send messages to "another user" while they actually transit through Facebook server. Skype is another example of P2P+server environment. If two users stand behind a NAT, it automatically uses a proxy server.
This is mostly the same with FB's XMPP, so you can go with that, unless your facebook users will see lots of strange messages in their chat window :)
I think you cannot build a multi-player game just by using facebook jabber servers. You will need to have a custom jabber component sitting at your own server to enforce your game business logic on the xmpp packets transferred between the game users.
This will (probably) involve writing custom Jabber Component Protocol XEP-0114 and Bosh Connection Manager component at your end. If you are looking to use PHP for developing your application you can have a look at Jaxl library (XMPP component and client library in PHP)

Iphone Game Dev Over The Internet

I was wondering is there an easy way to communicate between iphones over the Internet(Not LAN/Bluetooth) or must there be a dedicated server in which all the iphones running an application needs to connect to?
For instance, suppose I'm writing a game which works on the Internet. Once four clients joins a room, game starts. must I implement a server in which every Iphone client connects to (for instance if server was developed on Windows it could be a Service) or is there another way to address this when developing Internet-based application?
Thank you
We have an online game that uses the iPhone (see www.ownthisworld.com if you want an idea of what we have done). Basically we use a php back end that accepts requests and returns xml data to the phone. It works quite well, but it depends on how much data you would be sending and your expected response times. In any event, our architecture of PHP/MySql backend works fine for our needs. By using the normal internet route, you do not have to worry about firewalls so much either.
You'd at the very least need some sort of central match making service so that the iPhones would be able to find each other, which would require some sort of dedicated server.
Secondly, devices on the internet can't always simply do a direct connection with each other. If all of the devices are behind a NAT or a firewall that doesn't allow incoming connections, you'd need a central dedicated server to host the game on. If at least one of the iPhones can accept incoming direct connections, you could have that iPhone host the game for the others.
There are some ways to punch through a NAT, but they're generally pretty horrifying in their complexity, and you'd still need the central match making service to pair up players.