Jumpy movement with fixed timesteps

Started by
24 comments, last by krippy2k8 11 years, 8 months ago
Wha'ts the timer resolution set to? i remember reading somewhere that it can be as much as 15ms on some machines. This might acocunt for some backwards movements on some frames.

http://msdn.microsoft.com/en-us/library/ms712753

might help you manually set it.
Advertisement

I would try setting the fixed interval to something like 5 seconds, so you can actually see how exactly the jumps are happening. It could be that the interpolation is doing nothing, or that you are using alpha instead of (1-alpha), but it will be much easier to see this in slow motion.


Just tested this, i set my timer interval to 0.5 and only rendered at _prevPosition, it looked correct, obviously it jumped far when it moved, but it was not jittery or jumping back and forth. When i start interpolating again it get jittery, so it must be the interpolation.
The issues seems to go away when i turn of vsync, I wouldn't think though, if interpolation was the problem that it would atter.

Just tested this, i set my timer interval to 0.5 and only rendered at _prevPosition, it looked correct, obviously it jumped far when it moved, but it was not jittery or jumping back and forth. When i start interpolating again it get jittery, so it must be the interpolation.


That doesn't necessarily mean it's the interpolation, doing such large jumps could just be hiding the symptom.

How exactly are you calculating _prevTranslation and _nextTranslation? Are you directly copying _nextTranslation to _prevTranslation in your update function?

[quote name='JWBaker' timestamp='1344980241' post='4969604']
Just tested this, i set my timer interval to 0.5 and only rendered at _prevPosition, it looked correct, obviously it jumped far when it moved, but it was not jittery or jumping back and forth. When i start interpolating again it get jittery, so it must be the interpolation.


That doesn't necessarily mean it's the interpolation, doing such large jumps could just be hiding the symptom.

How exactly are you calculating _prevTranslation and _nextTranslation? Are you directly copying _nextTranslation to _prevTranslation in your update function?
[/quote]

The positions are being updated by Farseer Physics.

Yes i directly copy

public override void Update(float deltaTime) {
_prevTranslation = _nextTranslation;
_prevRotation = _nextRotation;
_prevScale = _nextScale;
base.Update(deltaTime);
}
you have a while loop on your update function and it changes the previous translation, rotation and scale each time it runs. doesn't this mean that there will be a disjoint when you have multiple updates between renders? The next trans,scale,rot ending one render frame will not equal the previous trans,scale,rot from the previous render due to the multiple update calls within the while loop.

I'm quite rusty and may be barking up the wrong tree here.
Iv attached a compiled version of the file, just a testing thing we made. If you check the gameplay testing part, it shows a moving box, this does not use physics, just translating the transform. The physics test uses WASD to pilot a ship, both tests should demonstrate my problem. Perhaps this will help diagnose. You need .net to run it.
I see a very rare jump on my system. What I'm seeing actually seems more like a timing spike to me.

Some things to try:

1) Try it in full screen mode if you haven't already.

2) Add something that displays a visual or audio indicator if while (accumulator >= dt) loops more than once in a frame, and see if it corresponds to any jumps.

3) Log the timestamps, translations and interpolations on each frame. You can just accumulate them in a memory buffer and then write it out when the game exits to avoid any lag for writing log entries to disk buffer for every frame. Then you can analyze the data to see if there are any anomalies like translating farther than the norm on any frames, or a translation that is behind the previous translation.


If still no joy then try to create the most minimal reproduction that you can to demonstrate the issue without disclosing any proprietary IP and post the complete source code.

I see a very rare jump on my system. What I'm seeing actually seems more like a timing spike to me.

Some things to try:

1) Try it in full screen mode if you haven't already.

2) Add something that displays a visual or audio indicator if while (accumulator >= dt) loops more than once in a frame, and see if it corresponds to any jumps.

3) Log the timestamps, translations and interpolations on each frame. You can just accumulate them in a memory buffer and then write it out when the game exits to avoid any lag for writing log entries to disk buffer for every frame. Then you can analyze the data to see if there are any anomalies like translating farther than the norm on any frames, or a translation that is behind the previous translation.


If still no joy then try to create the most minimal reproduction that you can to demonstrate the issue without disclosing any proprietary IP and post the complete source code.


hmm, i see somethign fairly regular and apparent. Ill build a very basic program and see what happens. Iv tried it in fullscreen, if you change the settings file you can too smile.png. I have checked for multiple update loops and sometimes it will happen once at startup, it does not happen after that from what i can tell. The logging i have done seemed ok, but ill try something more formal. Are you running win7?

I see a very rare jump on my system. What I'm seeing actually seems more like a timing spike to me.

Some things to try:

1) Try it in full screen mode if you haven't already.

2) Add something that displays a visual or audio indicator if while (accumulator >= dt) loops more than once in a frame, and see if it corresponds to any jumps.

3) Log the timestamps, translations and interpolations on each frame. You can just accumulate them in a memory buffer and then write it out when the game exits to avoid any lag for writing log entries to disk buffer for every frame. Then you can analyze the data to see if there are any anomalies like translating farther than the norm on any frames, or a translation that is behind the previous translation.


If still no joy then try to create the most minimal reproduction that you can to demonstrate the issue without disclosing any proprietary IP and post the complete source code.


Attached a very minimal amount of code to achieve the same issue, This red box moves very jumpy on my computer. I am logging a number of things to a file, but no numbers look out of place to me.

This topic is closed to new replies.

Advertisement