Jump to content
  • Advertisement
Sign in to follow this  
Elric

About entity synchronizing, animation times, frame times and movements -advice needed

This topic is 3828 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello, Finally I wrote my first server client application using Ogre3d and RakNet. It's a mini game that allows two player to connect and fight between themselves using ninja entity and animations that comes with Ogre. It runs on LAN so I assume there is no packet loss. But there are some problems that I need to ask. -About server main loop: When server and client runs on the same machine it slows down the computer. But in the real game applications this slow down is minumum that it doesn't have a big impact on the performance. So I assume they don't make the server loop run continuously. Is using sleep for the server a good way to gain performance? Is it possible to make sleep the server when there is no packet without using blocking sockets? Maybe some kind of packet listener...? -About entity movement synchronizing: The system I used for movement updates is -I think- the most basic and the worst one. Server sends the initial starting point for the clients. When a client presses a movement key, first it updates it's own world position and then sends packet -there is a timer to prevent packet overflow- that consists of this updated world position. Then server gets this packet, calculates the movement vector and sends it to the other client so that other client can translate the entity. The problem here is that both clients translate their own entity by multiplying their own frame time (time since last frame) with the movement vector. So there is happening a sycnhorinization problem when the game runs with different fps's on the different machines. Either the games need to run with the same fps values or I need a common time value. Or to be more specific, I need to make movements independent of time. Is there a way to achieve this? The same problem goes for the animation times... I will be very appreciated if I get some answers... Thanks.

Share this post


Link to post
Share on other sites
Advertisement
Quote:
Original post by Elric

When server and client runs on the same machine it slows down the computer. But in the real game applications this slow down is minumum that it doesn't have a big impact on the performance. So I assume they don't make the server loop run continuously. Is using sleep for the server a good way to gain performance? Is it possible to make sleep the server when there is no packet without using blocking sockets? Maybe some kind of packet listener...?


A CPU can do a given amount of work in some time period. If you have more work to do, then you have a performance issue.

Network code dealing with megabit LAN on any semi-recent CPU should not exhibit such issues.

You're most likely handling network data in a loop, regardless of whether there is anything to process. This results in tight nop loop, which affects OS scheduling, thereby leading to apparently decreased performance. This will likely be more apparent on single-core machines.

Sleep by itself would help, but there's better options to solve this problem, they depend on your actual network source.

Quote:
Is there a way to achieve this? The same problem goes for the animation times...


You can synchronize frame rates, and that is a technique that was sometimes used. Mostly however it's impractical.

You can use independent timer. On each frame, you query that, and extrapolate data from there. But since different clients advance extrapolations at different rates, rounding and accuracy errors will lead your simulations to diverge across clients. This will require you to send absolute values from time to time.

Share this post


Link to post
Share on other sites
I am stucked in my mind using timers to do movement. For example I press w and translate the entity by Vector(0,0, -100 * time). What should I choose as time?
If I use time since last frame, the final positions will be different with a machine that runs on 20 fps and another machine that runs on 60 fps. So sending exact positions won't do anything, because they are already different! So I need to select a time value that fits to all clients which connects to server. So comes the independent timer. But this independent timer also must depend on something to achieve consistent translations for the main models of clients. I don't know if I am thinking wrong...

Share this post


Link to post
Share on other sites
Hey Elric,

You might find this article interesting. It's about how multiplayer networking works in the Source engine. They talk about some of the similar problems you are facing, especially with regard to timing and interpolation.

http://developer.valvesoftware.com/wiki/Source_Multiplayer_Networking

Share this post


Link to post
Share on other sites
why dont you try this approach.

Client sends current position and current movement vector to server.

Server verifies move and can (possibly) even calculate where the client is now . I'm assuming here that you either timestamp the packet and that the server is aware of client local time. You can sync this during client server handshake.

Server then sends the clients current server position and movement vector to all observers. The clients can then do the same thing that server did (except verifying move!)

The observing clients now has enough information to move the object from where it thinks the object is and to where the server has the object.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!