Tag Info

Hot answers tagged

13

It's common for the client to implement some sort of feedback to let the player know immediately that their chosen action has been registered, eg.: interface sound (eg. button click) in-world sound (eg. a character saying, "At once, commander") animation (eg. begin swinging a sword) These can take place while the information is travelling to the server ...


10

I'll rather delve into the problem you are having with network latency: it's unavoidable. Network programming is a fine art and much more psychologically involved than tricking the eye (as you do with graphics programming); people are very sensitive to their perception of time. What you essentially need to do is do prediction on the client. For example, in ...


9

The IP protocol, atop which TCP and UDP are constructed, specifies that datagrams are neither guaranteed to arrive in order, nor via the same route, nor, for that matter, at all (thanks Trevor for the reminder). So, irrespective of whether TCP or UDP is used, latency will fluctuate. Latency is partly due to distance travelled, which changes if the path ...


7

Not sure if I properly understand your question, but I will take a stab at it. I would try using a quadtree (similar to a sparse voxel octree, but just 2D). You could represent the entire world as 4 quadrants, and then split each quadrant recursively where you want to achieve higher accuracy. See http://en.wikipedia.org/wiki/Quadtree Edit: to ...


6

Get rid of the Sleep call. Sleep is fine for reducing CPU usage, but it is not fine for controlling framerate, and these two are not the same thing. Sleep can have poor precision, in the order of ~16 milliseconds. Sleep guarantees that the thread will resume at some arbitrary time after the Sleep interval has elapsed, not at the exact Sleep interval. ...


6

Random thoughts: cheat: use rockets. Rockets explode in a radius, hiding any weirdness. cheat: predetermine the outcome and force the condition to happen visually cheat: attacks take time, hide latency in the atk+anim+result discontinuity cheat: disconnect local feedback from the networking stuff cheat: lots of VFX or screen activity that covers any ...


6

This will be hard to fix in so little time, especially since you're using such a peculiar structure, but well, let's give it a try. I'll post and edit as I notice the most glaring problems. Step 1) Proper Camera Panning The first thing that jumped out of your post like a madman was the part where you said: So, instead of the character moving, ...


5

This is probably not game development question, but yes. In normal IP connection, each packets may go through different intermediary "hops", and each different "hops" may have different latency. If you're using TCP to transfer your data, the protocol abstracts that for you and will reorder packets to deliver the packets in the order they were originally ...


4

You could also make lag be part of your gameplay for "realism" sake. Say your players are meant to control some robots from a distance, you could force the lag to be at least 500ms or 1s (you'd have to implement some dynamic lag padding system).


4

The correct way is to skip that frame and wait until the model is ready. If you find that the model update is taking too long, causing frames to be skipped too often, it's a better solution to optimize that instead of overcomplicating the code trying to be smart on the view side. A popular alternative is to use frame interpolation in the view, but it's not ...


4

The answer is quite simple - just build games that don't have time critical sections. You're looking to avoid implementing these types of interpolations for a specific reason I take it, which means you're not concerned about twitchy and fast gameplay. This is perfectly accetpable for a lot of games, including Civilization (which is a strategy game). However, ...


3

As Jonathan said, this is purely speculation. When I heard about "things getting laggier and laggier" the first thing that came to mind was a memory leak. I don't know how applicable this may be to your specific application, but my guess is that it is some sort of data leakage - data not being cleared when it should be.


3

Like Amplify91 said, it's not recommended to depend on a fixed framerate, even for an offline game. It's best to keep the game logic and rendering logic separated. The game logic updates the objects positions, statistics, and check for collisions and responds to inputs, and that is independent of the framerate because it's called at regular intervals. The ...


3

MySQL (in general, any SQL) is not the best choice for storing your live data. But I doubt that's your problem currently. It seems like your issue is that your game doesn't work with people connecting from outside the country due to the high latency. Possibly your networking code is embedded in your game loop somewhere, so a high latency network call is ...


2

Absolutely everything about an IP network can change at any time. The following article discusses how things like latency, packet loss, and throughput can vary and why: DEI Tech Note 0021: Loss, Latency, and Speed


2

This is something you simply have to test: Find a working revision. Start by reverting your version to the one before the update or the one where the roblem doesn't appear (you're using version control right, then this is very easy) and verify that the earlier version of the code doesn't have this problem. Never assume anything, always verify Pin-point ...


2

First Rq : A key rule in Javascript : avoid system lag, with a very simple principle : do not feed the garbage collector. So : Reuse your Arrays, do not create closures, use integers and not strings, pool your objects, ... a lot of simple rules too long to explain in a few words. Now that you've done that, to avoid a slow-down/ fast forward behaviour, you ...


2

deltaTime = (float)(currentTime - previousTick) / 1000000.f It's a simple floating point bug. When you divide an integer by another integer it returns an integer. This truncates all your decimal detail.


2

You are loading a graphic for every tile in every frame. Load it once at application startup that sould improve the speed dramatically.


1

The usual solution in order to avoid checking for every pair, would be to implement some kind of spatial partitioning like quad tree or bsp tree. but this might be too complex for your simple game. There are other trivial optimzations you can do in your loop: Calculate DistanceSqaured instead of Distance, because distance needs to calculate square root ...


1

You cannot solve this problem, but you can work around it by hiding the Windows mouse cursor and drawing your own. Or replacing the Windows cursor with your own. I explain the cause of the problem in detail in this answer. Basically Windows draws with the hardware cursor - which has an extremely low latency path from mouse-to-output. Any cursor you draw ...


1

Is it totally necessary to manage reload times server side? Often the simplest way to do this is on the client side for both fairness and responsiveness. I'm no expert but what I would predict is that the current system encourages spamming and the server has to check whether each request is valid before discarding it, taking up more processing power. ...


1

To start, there's a good post by Shawn Hargreaves on GameTime (more specifically, Fixed and Unfixed timestep) over here. Perhaps it will give you an idea or some things to try. However, I'm not entirely sure that you can rule out the garbage collector. For Garbage: Run your game through CLR Profiler and see what it tells you. If you have access to an ...


1

Another wild guess: perhaps you are not removing objects correctly and your collision detection gets out of control. Brute force collision detection scales very poorly.


1

You can make the grid size of each array twice as big as the last one, and let each tile in the lower-resolution grids equal to the maximum value of the smaller tiles it covers, see the figure below. That way they would be very easy and fast to update. For each lower-res array you get the wanted indices by simply dividing by 2. When a tile's value is ...


1

One approach to more fairly resolve conflicts would be to make the server logic work in turns, with very short fixed-time turns so play still proceeds in realtime. During each turn, the server collects all moves, but doesn't immediately commit them to the game state. A moment later, it closes the turn, detecting & resolving any conflicts in the moves ...


1

Aside from what's already been said, don't forget that routers are allowed to arbitrarily drop packets, meaning in TCP a packet could theoretically take arbitrarily long to reach its destination (and in UDP, it might never reach its destination!).



Only top voted, non community-wiki answers of a minimum length are eligible