Forum

> > CS2D > General > Any info on how the networking work is done?
Forums overviewCS2D overviewGeneral overviewLog in to reply

English Any info on how the networking work is done?

11 replies
To the start Previous 1 Next To the start

old Any info on how the networking work is done?

Yazir
User Off Offline

Quote
Hello. I am currently developing 2D top down shooter (like CS2D). I would only like to know how are projectiles synchronised in cs2d (every bullet in my game is a projectile with physical representation in the game world).

I am curious because it's not simple to make a good network code for realtime games and I'd like to know how it has been approached in CS2D which plays pretty well.

I would like to know how and when is data synchronised, movement, shooting etc.

old Re: Any info on how the networking work is done?

Starkkz
Moderator Off Offline

Quote
@user Yazir: Client side projectiles thrown by yourself are just a visual thing you see, the server notifies the actual projectile (that does damage and stuff) to the rest of the clients.

So there's a delay between the moment you threw the projectile and the moment the server figured out that you threw a projectile, which is added to the time where the projectile actually explodes.

Edit: The time a message takes to arrive from the server to the client or viceversa can't be worked out, however, you can work out client-side interpolation when you're trying to deal with object movement. (In order to predict where the object could possibly be moving to)

You could use interpolation techniques like; lagrange, spline.

old Re: Any info on how the networking work is done?

DC
Admin Off Offline

Quote
This is a complex topic. Make sure that the server is the only real authority and that it carefully checks all player input to minimize possible hacks, cheats and attempts to crash the server.

I'm sending the launch position and direction with projectiles in CS2D but only grenades and special weapons like rocket launchers have actual projectiles which are flying around. Of course the server has to validate if the player is close to the launch position to prevent cheating.

Shots in CS2D are not using projectiles. It's a simple message which only says "player x shot". No additional data. All other data like the current weapon and latest movement/rotation is sent with other packages. This is to minimize traffic as there are some high frequency fire arms in CS2D which shoot like every second frame.

Lag compensation in CS2D works by saving a list of old player positions. This allows you to go back in time to simulate the approximate game state at the time when the client shot locally.

I also implemented a tiny protocol on top of UDP to make CS2D work with a single UDP socket connection and minimal traffic. If you're using UDP directly you have to take care of things like reliable messages and message order as UDP is a simple "fire and forget"-protocol which doesn't guarantee that messages arrive in the right order or at all.

You should probably search for some articles and best practices as I can't tell you everything here

old Re: Any info on how the networking work is done?

Yazir
User Off Offline

Quote
@user Starkkz: I am using Phaser framework with Socket.io

@user DC: Thank you for the descriptive answer. I am searching for all the possible resources I can get to create the optimal (in terms of reliability and precision with least cpu and network usage). The information is not really anything new to me but it made me sure that I'm heading the right way

Also, the fact that I'm doing this on webSockets puts it a bit apart from CS2D since it requires a bit different approach (TCP only).

Nonetheless, thank you for your time and I understand the reason behind not being able to tell everything
To the start Previous 1 Next To the start
Log in to replyGeneral overviewCS2D overviewForums overview