Monogame Move objects while having a moving 2D camera

I am writing my first game. In this game, I have a heroEntity object, which has fields:

float X {get; set;}
float Y {get; set;}
Monogame.Extended.Camera2D Camera {get; set;}


Since I have some background, I use Camera.Move() instead of moving my heroEntity object (which I put at the center of the Camera.BoundingRectangle after each frame)

Now, I also a List<BulletEntity> Bullets (those bullets also have X and Y properties) and they should also move independently of the heroEntity.Camera object. When I simply implement movement of the camera and bullets independently, there is an impression that my bullets are kind of shaking.

How can I fix that?

• Without seeing it, my guess is that the shaking bullets has more to do with the frame rate than the camera. Although, I do find your camera setup quite odd. Could you post your Game class? The order that you're doing things in Update and Draw can also make a difference. – craftworkgames Apr 18 '18 at 6:06
• @craftworkgames I am first updating the bullets and then the camera. Is this the right way to go? – Philippe Apr 20 '18 at 12:26
• Updating the camera should not change the way your world evolves. Most of the time camera is just a viewport into your game rather than an actual and interacting object. You move the hero and the bullets independently, then you move the camera so that your heroEntity is at the center of the screen. – liggiorgio Apr 21 '18 at 14:35
• @liggiorgio Well, I move my camera and then put my hero at the center of the camera viewport – Philippe Apr 22 '18 at 5:32

I am not familiar with monogame, but if you have to code the Input manager yourself, then you might run into polling issues.
That is, if the bullets only shake when the hero moves.
I forgot why that issue occurs, but i am sure it has to do with code that is processed in between events. --> first poll all keyboard data and then simulate. Not both in between.
Of course there is also the possibility that your framerate is kind of out of sync.

If you can, i suggest implementing a sleep every frame for about 0.5 or 1 sec and observe the jitter closer.

Problem was solved by just changing the FPS from 30 to 60

TargetElapsedTime = TimeSpan.FromSeconds(1d / 60d)

Also, don’t forget to set the IsFixedTimeStep property to true