|
Other factors can contribute to lag, further compounding the consequences. Movement can be driven by animations, with velocity changes built into specific time points in an animation. For example, if the animator places the jump velocity impulse a fraction of a second into the animation to better match the visuals, it might look better, but it feels bad.
The animator can correct it by making sure the velocity impulse is on the first frame of animation when the player needs that immediate feedback. But then the question is how does triggering an animation translate into actual movement?
It's quite likely that animation updating is handled by the Render() function. Any events triggered by the animation will not be handled until the time around the loop, which adds another frame.
In addition, triggering an animation might not make it advance a frame until the next frame, delaying the event firing for a frame. Our lag could potentially be increased from six to eight frames, which would be quite unplayable, even at 60 frames per second.
That's not the end of it either. There are many other ways in which extra frames of lag sneak their way into a game. You might be pipelining your physics on a separate thread (or a physics processing unit).
What if you're using triple buffering to smooth your frame rate? You could be using abstract events that take a couple of passes through the system to resolve into real events. You might use a scripting language that adds an additional frame in the way it waits for an event.
It's quite possible to make your game logic incredibly flexible by abstracting various concepts of time and events, and yet while doing this, programmers can lose sight of exactly what's going on under the hood, making it far easier for additional frames of delay to creep in.
Responsiveness, Not Reaction Time
One of the great misconceptions regarding responsiveness is that it's somehow connected to human reaction time. Humans cannot physically react to a visual stimulus and then move their fingers in less than one-tenth of a second.
Game players' peak reaction times vary from 0.15 seconds to 0.30 seconds, depending on how "twitchy" they are. Quantifiables such as these are often brought up when discussing game responsiveness, but the connection is specious.
It's not how fast a player reacts to the game; it's how fast the game reacts to the player. The issue is not one of reaction times, but of synchronization.
Take Guitar Hero, for example, a game in which symbols come at you, the player, and you have to hit the correct button at a very precise point in time (when the target object is within a particular region). You are anticipating the future event, and there is no reacting involved at all.
The problems of lack of responsiveness occur when the game does not react fast enough to the player and the target object has moved beyond the target region by the time the event occurs.
If you press the button at the correct time, you do not expect the object to move even a few more pixels before it explodes. But since objects generally move at least a few pixels per frame, having a few frames of lag can permit the object to drift past its target.
Many action games are based around anticipation and button pressing. In a skateboarding game, you want to jump just before you hit the end of a rail. In a first-person shooter, you fire the instant someone moves in front of your gun.
Again, this is not reaction time. You usually have seen the target at least half a second before you shoot it, probably more, and will be either moving the gun, or waiting for the target to move in front of the gun.
Because of the somewhat unintuitive nature of these problems with responsiveness, it is important for programmers to fully understand the issues. The most important thing is to be able to clearly describe the frame-by-frame path through logic and rendering that a button-triggered action takes before it creates visual feedback. Once you have this, you can optimize it as close to the optimal pathway as possible.
[EDITOR'S NOTE: This article, originally published in Game Developer magazine, was independently selected by Gamasutra's editors, since it was deemed of value to the community. Its republishing has been made possible by Intel, as a platform and vendor-agnostic part of Intel's Visual Computing microsite.]
|
Say you want to fire an event upon the player touching the volume of a trigger, if the updates are too slow, the player will be well within the even trigger before its fired. This could lead to level designers feeling that there is something "untimed" about their design.
Now on the flip side, if this issue is not fixed early on in the production, then it will mean that the events in the levels, especially for a highly scripted game would have most likely been tuned with this bug; SO changing it or fixing it would break the pacing of your levels...
Another time to look for this problem is when engineers are in their "optimization" phase, one of the first things that gets tweaked is the collision system....and in a cube somewhere a level designer is pulling his hair out!
Articles like this (and thinking a lot about responsiveness) is, as stated, hugely important - player feedback is one of my hang-ups and can remove all feeling from a game if the delay is significant (a few fractions of a second even).
Thanks.
This is one area where old systems have an advantage. I guess the days of 1-frame reaction times, like with the good old NES, are over.
Another place I've found input lag is in the network layer. Where possible you want to simulate player actions on the client, so when you turn left you don't have to wait for your input to travel up to the server, be applied to the game state, travel back to the client, then wait for render. Strangely enough I even found this once in a single player game. Input events were being batched in a network queue, pumped to localhost, received, and then interpreted all on the same machine!
I done my best to squeeze the maximum performance of my mouse-reading and drawing func, and still it lagged several frames behind, when I turned on triple buffering, the lag was reduced, but if I turned on the system cursor I could still see that lag is still present...
fortunally I gave up :P since my code was already at the state of the mininum lag (ie: the optimum code that he described in the start of the article)
Maybe you guys don't even know what I am talking about, but hopefully some of you do. I think this is one of the biggest causes for me of that feeling of unresponsiveness.
http://cowboyprogramming.com/2008/04/23/running-in-circles/
However, having a concept of the "present" is important for handling lag that is unavoidable. In GH (and in most games), the game needs to be aware that the player is not seeing what it thinks what the current state is, but rather is seeing a few frames back. Games should allow the player a degree of slop in their synchronization to account for this. I touched on this in my "Pushing Buttons" article:
http://cowboyprogramming.com/2007/01/02/pushhing-buttons/
I've discussed the issue further here :
http://www.codermind.com/answers/How-do-I-reduce-mouse-lag-in-my-3D-application.
html
The irreducible part is : the latency of the mouse driver, the refresh rate (if you had really good control about refresh rate then it's possible to do better but that's usually something from the past like Amiga programming, not PC), and the LCD latency (LCD add latency too. They could add on average a whole frame of delay compared to an equivalent CRT and I'm not talking about remanence : see http://www.behardware.com/articles/632-1/lcds-images-delayed-compared-to-crts-ye
s.html ).