🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

Keeping track/updating data between players

Started by
2 comments, last by hplus0603 8 years, 8 months ago

Hello, just some questions on how to handle updating data between players. More of a design and implementation question.

When it comes to keeping track of players near each other, In my game, I only want characters in a certain range to be shown, as such the server only sends data to other players in X range around the player.

Right now, the server stores who we've sent player data to so we don't keep sending the full player state constantly (after the full player state, I just send position updates). But I'm running into problems with people going out of range, having their states changed, then moving back into view and the out of view clients obviously don't know (since the player state changed out of view). I figured the solution might be to delete the reference to the known player from the other player, so when it goes out of view so it refreshes. However, if someone is just moving in and out of view I don't want it sending full states constantly. It's been suggested to use a timer, so that once it goes out of view it has say, 1 minute before you delete the fact the other players know about you. Which is a good idea, but I'm getting wary of the server handling things like this that seem like it belongs in the client operation? I am not sure how other games handle this interaction.

What is the best way to go about this? Should the server be keeping track of which player knows about your player data and handling timeouts and view distances? I've also read some people have the client request data from the server. Example: You get movement data from a character that doesn't exist, so the client asks the server for info on this player. However, that starts having problems of queuing the initial request, waiting for the server to get the state data and send it back, then playing all of the queued up commands meant for that player when we create it.. Of course I'm not sure if that's correct as well. I guess I just need guidance on proper setup when it comes to this.

Thanks.

Advertisement
Who can see whom is absolutely a server operation.

An alternative to a timer is a distance hysterisis where you drop something if it's further than X*1.05 away, and you introduce something if it's closer than X*0.95 away, for some value of X.
enum Bool { True, False, FileNotFound };

Thanks, so to clarify, you would say my approach of tracing which players know about who has X data from a player, then managing it from the server is the right way to go?

I'll look into the hysterisis, seems like a viable option as well.

Yes. Typically, you will have a single "world state," and then a separate state for each connection, which manages what particular bits are "known" on that connection. That sounds like what you're doing.
enum Bool { True, False, FileNotFound };

This topic is closed to new replies.

Advertisement