XNA Creators Club Online
Page 5 of 6 (140 items) « First ... < Previous 2 3 4 5 6 Next >
Sort Posts: Previous Next

XNA Games 'jump', but professional games do not.

Last post 22/06/2008 23:13 by Nick Gravelyn. 139 replies.
  • 15/04/2008 11:45 In reply to
    • (23)
    • premium membership
    • Posts 3

    Re: XNA Games 'jump', but professional games do not.

    I wanted to add that I've seen similar issues already reported in the past years in a couple of thread:

    http://forums.xna.com/thread/39815.aspx

    http://forums.xna.com/thread/7653.aspx
  • 25/04/2008 5:03 In reply to

    [2.0] IsFixedTimeStep = true causes jitter

    Hi,

    i've done a simple test which tells me that the IsFixedTimeStep = true causes jittering. Firstly I could not figure what caused the jittering, but setting IsFixedTimeStep = false made the game run smoothly.

    I don't understand this. I've read the Shawn's article: http://blogs.msdn.com/shawnhar/archive/2007/11/23/game-timing-in-xna-game-studio-2-0.aspx which tells that when the timestep is true, Update is called as many times as needed to catch up to the current time

    How did i do this:

    I downloaded the sample "How To: Render a Model" from http://msdn2.microsoft.com/en-us/library/bb203933.aspx

    i modified the update method to respect the total game time to be accurate

            protected override void Update(GameTime gameTime)
    {
    RotationX = 30;
    RotationY = (float)(gameTime.TotalGameTime.TotalMilliseconds / 10);

    gameWorldRotation = Matrix.CreateRotationX(MathHelper.ToRadians(RotationX)) * Matrix.CreateRotationY(MathHelper.ToRadians(RotationY));

    base.Update(gameTime);
    }
    Even when i modified the update in this way:
            protected override void Update(GameTime gameTime)
    {
    RotationX = 30;
    if (IsFixedTimeStep)
    {
    RotationY += 2;
    }
    else
    {
    RotationY = (float)(gameTime.TotalGameTime.TotalMilliseconds / 10);
    }

    gameWorldRotation = Matrix.CreateRotationX(MathHelper.ToRadians(RotationX)) * Matrix.CreateRotationY(MathHelper.ToRadians(RotationY));

    base.Update(gameTime);
    }
    the jittering still occured if the IsFixedTimeStep = true.
     
    Is there any clarification of this?
     
    Thank you
  • 25/04/2008 5:13 In reply to

    Re: [2.0] IsFixedTimeStep = true causes jitter

    This "jitter" that happens when FixedTimeStep is true has been encountered by a bunch of people, but no clear answer had been found.

    Can you give us the following information:
    • the PC you're running it on (CPU, RAM, GPU)
    • Operating System
    • are you running Windowed?
    • What happens when you switch to fullscreen?
    • finally... can you give us repro application? A zip would be fine
    What happened most of the times I tried running other people reproduction cases, was that it ran just fine on my PC. So it's probably the hardware.

  • 25/04/2008 7:48 In reply to

    Re: [2.0] IsFixedTimeStep = true causes jitter

    It behaved the same on these configurations:

    •  Intel Quadcore 6600 2.4Ghz, 3gb RAM, Geforce 7600GT, Windows Vista
    •  Intel Quadcore 6600 2.4Ghz, 2gb RAM, Geforce 7100GS, Windows 2003 R2 .

    Both running windowed

    Switching to Fullscreen caused even the IsFixedTimeStep = false version to jitter on the 7100GS 1280*1024

    here is the code and executable

    http://net.aspone.cz/Model.zip

  • 25/04/2008 8:16 In reply to

    Re: [2.0] IsFixedTimeStep = true causes jitter

    Just as I feared. The sample works well on the machine I am using right now (Athlon 1800+, GeForce 5700). I didn't notice any jitter.

    I'm not sure what to suggest. It might be a driver issue, so try installing the latest drivers from the NVIDIA site. If all else fails, try putthing it on Connect, together with the reproduction and a detailed description of what happens on every system.
  • 25/04/2008 11:32 In reply to

    Re: [2.0] IsFixedTimeStep = true causes jitter

    Mod: Merged this thread into the original large thread regarding jumps and jitters. Please read the whole thread for more information.
    Play Kissy Poo - a game for 4 year olds on Xbox and windows
    The ZBuffer
    News and information for XNA
      Follow The Zman on twitter, Email me
        Please read the forum FAQs - Bug/Feature reporting
          Don't forget to mark good answers and good playtest feedback when you see it!!!
  • 23/05/2008 7:05 In reply to

    Re: XNA Games 'jump', but professional games do not.

    I had the very same problem in my project.  My sprite movement would jump every 20th frame or so.  After digging around, I finally concluded that every 20 frames or so, my Update method got called twice (probably because of the GC, but my profiling didn't match up with that....any XNA Devs know why?).  Because my Update method was being called twice, I was taking input from the controller twice.  So when my game finally got around to drawing the next frame, my sprite had jumped a whole two units of position.  This would also explain why some people were having success with changing to variable timesteps.  With a variable timestep setup, it's impossible for Update to be called twice for a single Draw call.
  • 23/05/2008 11:22 In reply to

    Re: XNA Games 'jump', but professional games do not.

    If you have a fixed timestep you basically have a choice here.

    1) Ensure that all your updates and draws get processed in time - set a min target spec machine and ensure you hit your update time.  If some other process kicks in and interferes with your game, live with it - this what happens when writing games for Windows.  If it's the GC - fix up the problem by allocating memory upfront and reusing objects.  Don't update your HUD every frame (score.ToString(SCORE_FORMAT), etc), only when info changes

    2) Try to interpolate / extrapolate the drawing position.  For interpolation - work out how much of the current frame has passed and lerp between previous and current position.  You could even try smoothing updates by keeping a list of the last x update times and averaging them.

    http://www.flipcode.com/archives/Main_Loop_with_Fixed_Time_Steps.shtml

    The nested discussion died with Flipcode but the main post is there for you to get the gist.

    I used to do 2 but it quickly becomes a pain IMHO.  Now I use 1.  I don't tend to write 'casual' games so am happy to target gamers with a higher than average system.


    Cheers, Paul Cunningham Pumpkin Games
  • 23/05/2008 20:40 In reply to

    Re: XNA Games 'jump', but professional games do not.

    To work around that, turn ON Vsync, but turn OFF fixed time step, and do your own fixed time step calculation if necessary.

    Jon Watte, Direct3D MVP
    Tweets, occasionally
    kW X-port 3ds Max .X exporter
    kW Animation source code
  • 23/05/2008 20:52 In reply to

    Re: XNA Games 'jump', but professional games do not.

    I used to roll my own fixed step loop too - physicsy type game objects updated deterministically, particles and effects as and when.  I prefer the simpler approach now though.

    And anybody that doesn't sync to refresh must have broken eyes - tearing? yikes!
    Cheers, Paul Cunningham Pumpkin Games
  • 24/05/2008 2:07 In reply to

    Re: XNA Games 'jump', but professional games do not.

    Whiplash6:
    I just got World in Conflict and notice the jump there too.  Wonder why it doesnt jump on any of my other games.  So what can cause this jumping besides a video card since I went through 2 already (testing with 2, not 2 were damaged).

    I think Whiplash's problem is/was simply that something is grabbing the cpu periodically resulting in dropped frames, so his is not really an XNA issue at all, though the discussion of how to program around things like this is interesting.

    Did you ever try changing the priority of your game in the task manager to High or even RealTime (save your work first) to see if that fixes it?  If not it might be a hardware/driver issue.  Try unplugging all peripherals (especially USB devices including hubs) and even stripping the box down to the bare minimum if you have to.  If you can get to a state where the problem is gone, then you can put things backk one by one until you figure it out.

    One lonely peripheral with a crappy driver would explain all of his problem I would think.  It's probably *not* the video card, but something that's periodically interrupting the system looking for attention and the driver's running so long to handle this that you drop a frame (or even multiple ones).

    F.

  • 24/05/2008 9:06 In reply to

    Re: XNA Games 'jump', but professional games do not.

    Another cause for periodic dropped frames in Windows Vista is having the clock widget active on the sidebar with the second hand displayed.  I noticed a regular stutter that occurred once per second in games, and eventually realized that the only thing that might be grabbing the GPU with such an exact frequency would be that second hand on the clock widget.

    Sure enough, I unchecked the option for displaying the second hand and the problem vanished.  If I turn it back on, the problem returns, so there's a clear causal relation between the stuttering and the second hand on the clock.  Needless to say, I don't run the sidebar anymore, because of such interference.

    As for XNA's problem, I suspect it's a combination of things within the framework itself, not limited to the garbage collector.  I strongly suspect delays in synchronization mechanisms at the operating system level as well as the software mechanism for fixed timesteps, which could all cause the games to play catch-up more frequently than they should have to, given the high computational power of some of your boxes.  In addition, there will of course always be the occasional hiccup introduced by a multitasking OS, although it may not be as consistent or easily identifiable as the sidebar clock example that I gave.

    In any case, if you have any synchronization going on at relatively large intervals (refresh rate, fixed time step, etc.), you're going to run into glitches, which are unfortunately noticeable at such a large time scale.  In fact, any synchronization will artificially lower the specs of your machine, because synchronization implies some waiting around for things plus overhead for relinquishing and reacquiring control.  These are just some things to think about.
  • 24/05/2008 20:08 In reply to

    Re: XNA Games 'jump', but professional games do not.

    I get the periodic jitter on fixed time-step as well.When I go to non-fixed time-step it goes away. Machine:

    - Win XP Pro

    - Intel Dual Core 2.2 Ghz

    - Nvidia 7900 GTX

    - LCD Monitor 59hz refresh


  • 24/05/2008 23:07 In reply to

    Re: XNA Games 'jump', but professional games do not.

    It's Fippy, the bane of n00bs everywhere! Qeynos dwellers, beware!!1!

    Anyway, yeah, fixed time step don't work so well in XNA, because it's implemented at the wrong place, and/or you can't perfectly match the Vsync interval with your intended fixed time step. If you want to use fixed time step, you should set it to something that isn't too close to 60 -- say, 100, or perhaps 120.

    Jon Watte, Direct3D MVP
    Tweets, occasionally
    kW X-port 3ds Max .X exporter
    kW Animation source code
  • 25/05/2008 2:14 In reply to

    Re: XNA Games 'jump', but professional games do not.


    I still fail to believe it is the fault of the framework alone. I have not had this issue with my games using both my laptop and my old tower PC. George also reported that he has worked on XNA games on five different machines ranging from laptops to towers and with varying hardware and he also has not seen this issue. Perhaps some monitors have an issue with matching the vsync with the XNA timestep, but it certainly then involves a specific hardware/driver.
  • 25/05/2008 4:35 In reply to

    Re: XNA Games 'jump', but professional games do not.

    I've been running some tests on the Xbox, mostly with my own code, but also observing the available games for download from the Community (if case your wondering, most of those games also have the stutter) and have come to three possible causes for this, all of which may to occuring at any given time during gameplay  :

     Update takes too long, a second Update is called to catch up to the correct time, so internal movement is updated twice for the subsequent draw frame.

     Draw takes too long, so Update is once again called twice in a row to catch up to the current time, updating internal movement and position twice.

     The Framework jumps in and freezes the Update-Draw cycle in order to do some housekeeping, causing the game to fall behind and once again have to call Update twice in a row.

    The first two scenarios can be caught and avoided in the game code I believe, using a combination of IsRunningSlowly, ElapsedGameTime and ElapsedRealTime.  The third scenario though, I haven't figured out a way to recognize.  It seems whenever the Framework jumps in to do housekeeping, the values for IsRunningSlowly flag and the elapsed times will vary depending on where in the Update-Draw cycle the Framework jumped in at.  Anybody have any ideas or other theories? 

  • 25/05/2008 6:00 In reply to

    Re: XNA Games 'jump', but professional games do not.


    charlie:
    Update takes too long, a second Update is called to catch up to the correct time, so internal movement is updated twice for the subsequent draw frame.

     Draw takes too long, so Update is once again called twice in a row to catch up to the current time, updating internal movement and position twice.

     

     I'm not sure how Update() or Draw() could take too long when running the samples provided on this site. They are very small amounts of code.

  • 25/05/2008 7:34 In reply to

    Re: XNA Games 'jump', but professional games do not.

    I just realized you were the guy behind Alien Aggressors...and...yeah, on the 360, your game has the same sprite stutter : ( .
  • 25/05/2008 18:29 In reply to

    Re: XNA Games 'jump', but professional games do not.

    Been a while since I looked at this thread.  Had to deal with some personal issues the past few weeks.  Anyway, i just downloaded the RPG Starter Kit and there is NO sluggish gameplay (no jumping AT ALL).

    Now, I do get the jumping on very very basic games (you mentioned Alien Aggressors and I get it on that game as well) and I also get it in the professional created game World in Conflict.  I recently got the nVidia 9600GT and it still does the jumping. 

    Yet I barely get this in the Net Rumble starter kit and I never get it in the RPG starter kit.  But every small sample provided by MS (aiming sample for example) I get major jumps.

  • 26/05/2008 4:24 In reply to

    Re: XNA Games 'jump', but professional games do not.

    Alright, here is just about the most simple program possible to demonstrate any slowdown during XNA programs.

    http://www.nfostergames.com/ZippedPrograms/XNAFixedTimeStepTest.zip

    This holds a cornflower blue background during times which is gets more than ~40fps, if it ever drops below that the screen will turn red.

    My personal results:
    Fixed timestep: Screen flickers red every couple of seconds, very briefly.
    NO fixed timestep: Screen still flickers red, but slightly less often.
    NO fixed timestep, AND vertical retrace turned off: Screen only flickers a couple of times initially, then stays blue for at least the next minute.

    I had less red flickers during fullscreen mode.

    My guess is that either XNA has a problem, or background Windows apps briefly interrupt (which is why windowed mode sees this more), or occassionally XNA ends up waiting for the GPU slightly too long with slows the next frame a bit.

    XNA QuickStart Engine (3D Game Engine for XNA) | My site
    "I'll be whatever I want to do!", Philip J. Fry
  • 26/05/2008 5:28 In reply to

    Re: XNA Games 'jump', but professional games do not.

    Alien Aggressors is a horrible game to use for comparison. As the author I can say this with 100% certainty. That game does nothing to keep garbage levels down so you are quite likely to get those frequently which will destroy any hope of finding a flaw in the XNA framework. Every string on the screen is a string literal in the Draw method using standard concatenation to combine strings making even more allocations. Each laser is created as a new class when fired and is simply released when off screen or a collision occurs. I did that for two reasons: 1) it works pretty much perfectly on my machine and 2) it was just a game made for a tutorial on how a beginner can make a complete game so optimizing was never part of the agenda for me.
  • 26/05/2008 5:32 In reply to

    Re: XNA Games 'jump', but professional games do not.


    Lord Ikon:

    Alright, here is just about the most simple program possible to demonstrate any slowdown during XNA programs.

    http://www.nfostergames.com/ZippedPrograms/XNAFixedTimeStepTest.zip

    This holds a cornflower blue background during times which is gets more than ~40fps, if it ever drops below that the screen will turn red.

    My personal results:
    Fixed timestep: Screen flickers red every couple of seconds, very briefly.
    NO fixed timestep: Screen still flickers red, but slightly less often.
    NO fixed timestep, AND vertical retrace turned off: Screen only flickers a couple of times initially, then stays blue for at least the next minute.

    I had less red flickers during fullscreen mode.

    My guess is that either XNA has a problem, or background Windows apps briefly interrupt (which is why windowed mode sees this more), or occassionally XNA ends up waiting for the GPU slightly too long with slows the next frame a bit.

    Here are my personal results as well:

    Fixed timestep: A few red flashes during startup and then one every 30 or so seconds
    No fixed timestep: A flash maybe every once a minute tops. Probably less than that.
    No fixed timestep and no vsync: No flashes ever (within the 2-3 minutes I ran the game)
    Fullscreen (fixed timestep and vsync both on): No flashes ever

    So I'm still convinced that while there might be some part of the XNA framework that exascerbates this behavior, I do believe that the specific hardware and drivers also play into this. I never notice the jump in any of my games on Windows; only in these little demos where the screen is flashing at me.

  • 26/05/2008 5:39 In reply to

    Re: XNA Games 'jump', but professional games do not.

    Nick Gravelyn:

    Here are my personal results as well:

    Fixed timestep: A few red flashes during startup and then one every 30 or so seconds
    No fixed timestep: A flash maybe every once a minute tops. Probably less than that.
    No fixed timestep and no vsync: No flashes ever (within the 2-3 minutes I ran the game)
    Fullscreen (fixed timestep and vsync both on): No flashes ever

    So I'm still convinced that while there might be some part of the XNA framework that exascerbates this behavior, I do believe that the specific hardware and drivers also play into this. I never notice the jump in any of my games on Windows; only in these little demos where the screen is flashing at me.

    Personally, I use elapsedGameTime in all movement functions. It doesn't matter if I'm getting 2fps, or 200fps, I'll be moving the same speed either way. The only way I see this causing an issue is if people are relying on the fact that they'll be getting a fixed speed at all times, which is a bad assumption considering everyone's computer will be running different hardware and software combinations.

    XNA QuickStart Engine (3D Game Engine for XNA) | My site
    "I'll be whatever I want to do!", Philip J. Fry
  • 26/05/2008 10:13 In reply to

    Re: XNA Games 'jump', but professional games do not.

    Actually, both those starter kits (NetRumble and RPG) have the sprite jumping too.  Those two games, however, sort of mask the jumping by keeping the main ship/character in the middle of the screen as much as possible, and moving the background around them.  If you watch the starfield in the the background in NetRumble and the background sprites in RPG Game, you will see the sprite jumping.  So unless I drastically change my game design (keep the player avatar in the middle of the screen, and move the background to simulate movement throughout the world), my game is gonna have to live with the sprite jumping :( .
  • 26/05/2008 15:25 In reply to

    Re: XNA Games 'jump', but professional games do not.

    It does not matter if I use elapsedGameTime or not.  It will still jump.  It still jumps regardless if isfixedtimestep is true or false (but not as much).  I used alien aggressors as an example because its basic, and anything basic will jump.  It doesnt matter how you handle the objects in the game, it will still do this (as mentioned by NetRumble).  Even samples from MS showing aiming, movement, rotation, and so on. Seems to happen far less in 3D games but I have found it in 2 professionally created games World in Conflict and Warcraft 3 frozen throne (Menu background does this with the snow)  Yet there are several games that do not do this (including XNA games)  So what is going on?  I have 3 computers, and all 3 have the jumping!

     

    Now it could be my computer, but with lots of people experiencing the same problem with different hardware configurations makes it seem unlikely.

Page 5 of 6 (140 items) « First ... < Previous 2 3 4 5 6 Next > Previous Next