[SOLVED] How to make movement loop in game update??

I have list with coords to move
I loop list in update
and then I loop coords inside
but my game freezes and my object gets to destination at the end and unfreezes.

how to make movements like this in monogame ?

basicly Iam getting teleport, not movement

Don’t use a loop. MonoGame calls Update in your Game1 every frame. Just do the movement once in Update and it will happen every frame.

You can use the gameTime passed to update to make sure the movement is not dependent on the time a frame takes by giving your objects a speed and every frame adding speed * timeSinceLastUpdate to their position. That way their speed will be consistent regardless of frame rate. If you don’t do this and instead add a constant value each frame, at a frame rate of 60 your objects will move twice as fast as at a frame rate of 30.

1 Like

ty I will try refactor my code :slight_smile:

Ty for help I fixed it.

1 Like