Jerky vehicle movment.
Jerky vehicle movment.
Hi again
My vehcile moves a bit jerky. Don't know why. Some frames it seems to stall. (not much, but enough to be irritating)
Can it be the wheels getting stuck in the car body? The rest of the game moves smoothly. ( I've added animated object that move around the world to be sure )
This video shows what I mean. Sorry for the bad quality And I hope you have the codec.
http://www.scavenger.se/vehicle.avi
My vehcile moves a bit jerky. Don't know why. Some frames it seems to stall. (not much, but enough to be irritating)
Can it be the wheels getting stuck in the car body? The rest of the game moves smoothly. ( I've added animated object that move around the world to be sure )
This video shows what I mean. Sorry for the bad quality And I hope you have the codec.
http://www.scavenger.se/vehicle.avi
Re: Jerky vehicle movment.
That's odd. My first guess would be continuous collision detection. The car body may be thinking it's going to hit something based on its velocity and only integrates forward enough to check for that collision rather than all the way through the step, leading to an unsightly jig.
Does it still happen if you change the CCD mode or turn it off?
To use linear continuous collision detection only:
To turn it off:
Other possibilities could include something to do with timestepping, though I'm not sure what yet.
Does it still happen if you change the CCD mode or turn it off?
To use linear continuous collision detection only:
Code: Select all
space.simulationSettings.collisionDetection.collisionDetectionType = CollisionDetectionType.linearContinuous;
Code: Select all
space.simulationSettings.collisionDetection.collisionDetectionType = CollisionDetectionType.discreteMPRGJK;
Re: Jerky vehicle movment.
Thanks for the fast answers!
I run at a stable 30fps.
I'll try your suggestions right away!
I run at a stable 30fps.
I'll try your suggestions right away!
Re: Jerky vehicle movment.
I get the same result with the two collision detection types. =(
Re: Jerky vehicle movment.
Alrighty, that's good and bad. The good is that CCD isn't bugged, the bad is that I don't know exactly what's wrong yet
You said you had a purely animated shape running around; it doesn't have any jigs whatsoever when the car jigs? Is its position updated in the same area as the space-update?
Are you currently using internalTimeStepping?
Right now I'm just trying to gather information, since I'm not exactly sure what is causing it.
You said you had a purely animated shape running around; it doesn't have any jigs whatsoever when the car jigs? Is its position updated in the same area as the space-update?
Are you currently using internalTimeStepping?
Right now I'm just trying to gather information, since I'm not exactly sure what is causing it.
Re: Jerky vehicle movment.
Yes I added a simple model that just moves from one side of the screen to the other and back. It moves smoothly.
It is updated with the same dt as the space.
The time step duration is set to be the same as the screen refresh rate. I've tried both 1/60 and 1/30. The game waits for the vsync.
It is updated with the same dt as the space.
The time step duration is set to be the same as the screen refresh rate. I've tried both 1/60 and 1/30. The game waits for the vsync.
Re: Jerky vehicle movment.
I've tried both on windows and xbox360.
Re: Jerky vehicle movment.
When you say it is updated with the same dt as the space, is it a flat 1/30 (or 1/60) each call to Update, or are you passing the elapsedGameTime.TotalSeconds?
There may be a frame stutter which the animated object deals with by moving further due to a longer elapsed time, while the engine only moves forward 1/30 (or 1/60) of a second. If this is the case, you can enable internal time stepping:
The engine will try to simulate the space.update passed-in value by taking a number of 1/30 (or 1/60) steps. If there's time left, it will interpolate some of the entity's properties to avoid a jerky appearance. Interpolated properties include orientationQuaternion/orientationMatrix, centerPosition, and worldTransform (so you'd have to use one of them to set the graphics transform instead of an "internal" property like internalCenterPosition).
There may be a frame stutter which the animated object deals with by moving further due to a longer elapsed time, while the engine only moves forward 1/30 (or 1/60) of a second. If this is the case, you can enable internal time stepping:
Code: Select all
space.simulationSettings.timeStep.useInternalTimeStepping = true;
Re: Jerky vehicle movment.
Now when I increased the velocity of the animated object I see it is moving like the car.
So there's nothing wrong with the physics.
Sorry...
Thanks for your help!
I hope I didn't waste too much of your time =)
So there's nothing wrong with the physics.
Sorry...
Thanks for your help!
I hope I didn't waste too much of your time =)
Re: Jerky vehicle movment.
No problem
Re: Jerky vehicle movment.
By the way, it looks a lot like a garbage collector jig (particularly if you notice it more on the Xbox than the PC). Running a release-compiled version through CLR profiler might provide some helpful debugging information for you. That, and the "XNA Framework Remote Performance Monitor for Xbox 360" that comes with XNA Game Studio would help narrow things down.
Re: Jerky vehicle movment.
I've run the performance monitor and made sure no allocations are made after initialization.
So, it's not the GC.
I'll try the CLR profiler
So, it's not the GC.
I'll try the CLR profiler
Re: Jerky vehicle movment.
Found it!
A very simple error. But I've been looking for it for ages!
I had both sync to vsync AND fixed time step enabled in my Xna.FrameWork.Game
Now it runs smoooth!
I'm soooo happy =)
A very simple error. But I've been looking for it for ages!
I had both sync to vsync AND fixed time step enabled in my Xna.FrameWork.Game
Now it runs smoooth!
I'm soooo happy =)