I'm using cocos2d 2.0 and Gamekit for networking. I've got a server/client model. It works over wifi (local) and bluetooth. (Xcode 4.3, Objective C)
Basically, there's a ball and 2 or more players. What I wanted to do is:
The physics is completely simulated on the server. The clients send their inputs to the server and the server sends the position (only the position and rotation that's it) to the clients. The clients than set the position of the objects to the given position datas. The ball is also simulated on the server.
Problem: There can be a high latency and the gameplay would be not smooth on the client side. The players can freely move around and interact with the ball (just pusing it and such things).
I read about prediction but how should it be possible to guess the movement of the player? The player can move completely free (360°). I also read about Servertime and clienttime but I didn't get it very well :/
How could I reduce lag? Please explain your solution because I don't want to just copy and paste it, I want to understand it.
PS: Probably I will have very low ping (1-5 ms) on wifi (local, both devices on the same network), I guess but I want to implement Gamecenter too and than I would need to handle the lag. But handling the lag on wifi/bluetooth would be great to, to achieve smoother gameplay.