Home Tutorials Download Beta Store Forum Documentation KnowledgeBase Wiki Blog

ShiVa3D

Return to Networking

Client prediction and other things

How to get the best of multi player experience

Client prediction and other things

Postby DarkSoul » 17 Aug 2012, 13:06

Hello everyone!
I have been going through some personal problems and I have been very busy, but I am back! and I have a new project to develop, an experiment...
I'm very happy with the idea. I have based this game on "Corridors" (you can see the game here: http://www.lastvisiongames.com/free_games_en.html).

This game will be multiplayer online and much better than "Corridors" ofcourse, the game will be free for Windows, Mac and Linux =)

For make this game, I have some quiestion because yet this days I'm very confused with implement multiplayer mode in a game, so I need your help in this if you have experience on it. For example, the last time than I try to create a multiplayer game, when I create the server player and client player, server player creating two characters in the Shiva editor, but out of Shiva editor, in the compiling version, the server create one character, this is confusing for me, why happens?

Well, now my real questions:

1. When I create characters (for server player and client players), how I need configure this entities? for example, the collisions, need physics collisions, standard collisions...?
I know the own character has the dynamic controller and dynamic collisions, but the others? When I say "others" I mean to the other players, his characters move in your screen from the events, "you are now in x,y,z position and I send to you the new position and my character in your screen translate to the new position", what collision kind I need to this other character if I want to collide with they?

2. The major problem for my, because I don't understand anything about this... Client prediction. I wanted make this game in Torque 3D because the multiplayer system is already programmed, with client prediction and all you need, but I like Shiva and I will like to try with it. So, anyone can help me with it? one shiva example, some tutorial oriented to shiva... I think StoneTrip should make something like this, an example of client prediction.

I think that is all. Thank you very much!
http://www.lastvisiongames.com
Do not dream, do it.
User avatar
DarkSoul
Gold Boarder
Gold Boarder
 
Posts: 221
Location: Spain

Re: Client prediction and other things

Postby DoctorPepper » 17 Aug 2012, 13:20

DaveYoung has written server based code for networking, among other things. There is a codedrop and sample videos that demonstrate multiplayer movement and combat. http://daveyounggames.com/
User avatar
DoctorPepper
Platinum Boarder
Platinum Boarder
 
Posts: 474
Location: Belgium

Re: Client prediction and other things

Postby dtr1au » 18 Aug 2012, 00:38

Multiplayer networking is a massive topic.
It's something that can become very complex very fast depending on your game.

A really awesome presentation can be found here:
http://gdcvault.com/play/1014345/I-Shot-You-First-Networking

It gave me heaps to think about, and shows how complex these networking systems can become depending on your game. On the surface they might not sound that complicated, but trust me, when you need all that to work together at once it becomes tough, and is why these big games have dedicated network programmers/engineers, that's all they do.

Also, with shiva3d, the networking built in is all TCP based, you can use it, but you ultimately will need to write your own plugin using UDP in order to get desired results.

I am trying to work on multiplayer networking, but I am learning more and more about how long it really does take to get going, and you really should plan from the start to implement the networking, don't build your game then come back and hope to implement a nice networking solution... it's too difficult and might change much of your design to work nicely with the networking.
dtr1au
Platinum Boarder
Platinum Boarder
 
Posts: 375
Location: ACT, Australia

Re: Client prediction and other things

Postby Fraser » 18 Aug 2012, 02:03

Guys,

As dtr1au says, TCP over WAN is not good for FPS, I think/hope UDP support will come in shiva2.

Writing different UDP plugins for different platforms is possible now but painful to mantain/expand codebase for all platforms. I won't bother.

If you choose a game mechanic with high inertia (like helicopter or hot air balloon or rolling big metal balls etc) then using cubic (along with current control state) you can extrapolate before TX and take yourself 1 second or more into the future.

All incoming translation/rotation messages go into a cyclic buffer table, RX side strives to mantain constant space between tables read/write indexes. Discards messages or adds fakes with interpolation.

High object inertia means msg frequency can be lowered to say 5Hz and still be able to reproduce path accurately with cubic interpolation.

Kalman filter is not necessary for getting to the future. Cubic extrapolation is much easier. each dimension is treated seperately with less CPU cost.

using this scheme then zero lag game over WAN might be possible without too much pain.

I am thinking of making a helicopter racing and/or battle game with LAN and eventually WAN play (with own server).

I too realise it is easier to talk about it than do it :mrgreen:
Fraser Ashworth,
https://www.cortex7.net
User avatar
Fraser
Platinum Boarder
Platinum Boarder
 
Posts: 1104
Location: Europe

Re: Client prediction and other things

Postby DarkSoul » 18 Aug 2012, 08:54

Guys, thanks for the links ^^
As dtr1au says, TCP over WAN is not good for FPS, I think/hope UDP support will come in shiva2.


Well, I have not problem with that because my game is not a FPS, don't need shooting. I know how to make a multiplayer game, I have done it other times (just examples but working examples), my problem is just the client prediction. In my game, just I need to synchronize the players position, the enemy position and some other objects position like doors. I also want to try synchronize the physics, but I know this is more difficult.
http://www.lastvisiongames.com
Do not dream, do it.
User avatar
DarkSoul
Gold Boarder
Gold Boarder
 
Posts: 221
Location: Spain

Re: Client prediction and other things

Postby Fraser » 18 Aug 2012, 21:21

Getting realtime accurate position of all clients is what I am interested in also, I think one method is have server process synchronise all client clocks.

server resets own clock: application.resetTotalFrameTime ( 0 )

Then do this for each client:

[1]
Server sends client[X] application.getTotalFrameTime() using a custom message.

[2]
client[X] then loops 5 times calling server.getCurrentPingDelay ( hServer ) to work out average current server ping. If the pings have noise outliers then goto [1]

[3]
Client[X] then adds half ping time onto time received in [1] and calls application.resetTotalFrameTime ( n )

Clock drift on modern devices is negligible for sessions spanning hours.

After clocks are synchronised then messages can be timestamped allowing for accurate extrapolation however you want, many will suggest kalman filter.

To synchronise physics: one way is to run the dynamics only on the server (in LAN) or one client (in WAN). Other players do not run physics on those objects but receive their positions (same as other player positions). So all physics running on one device, box hitting other players etc. with TCP it would be difficult to get tight, but maybe acceptable.
Fraser Ashworth,
https://www.cortex7.net
User avatar
Fraser
Platinum Boarder
Platinum Boarder
 
Posts: 1104
Location: Europe


Return to Networking