I am new to MonoGame, I’m making a Pong clone. the ball for some reason seems to have a jerky motion like its skipping frames. I have tried both fixed time step and variable time step. I have turned Vsync on and off. Nothing seems to change, this persists on both PC and android device.
I simply add a velocity vector to the ball’s position (position += velocity * gameTime.ElapsedTime.TotalSeconds).
My game requires the ball to move fast, so I scale the unit velocity vector to 400.
but even with smaller values the results don’t change.
Can some one please tell me what I might be doing wrong?
bump have same problem thought it was just my eyes.
Actually check this out Note on frame skips and jerkiness even though you’re probably not using BasicEffect, if you’re not disposing other objects correctly/creating alot of them each frame it might cause this. Try moving things like new Rectangle(x,y,width,height) for example to the update loop.
Could you post video please?
Sounds like you might be hitting the garbage collector. Try not to “new” up objects in update and draw methods.
You’re better off profiling your game with Xamarin profiler to see what’s the real problem
Hi thanks a lot for the reply. That seems to have been the problem. I had and 2 updates called for every draw.
So I’m just going to try to be more careful.
is vector2/rectangle okay for each update draw?
I’m not sure what you mean exactly, but I’m trying not to use ‘new Vector2’ or ‘new Rectangle’ in the update or draw, and it seems to be helping.
Vector2, Rectangle and other structs containing POD (Plain Old Data) types are fine to “new” as they are allocated on the stack. Classes and boxed types get allocated on the heap which does impact the garbage collector.