Applying matrix to SpriteBatch

Okay folks, I am basically using this code: http://www.david-amador.com/2009/10/xna-camera-2d-with-zoom-and-rotation/ for my camera. Everything works fine, except when applying it to the SpriteBatch. I have a unit at position X:400 and Y:400 for testing. So technically when I start the program it should roughly be up there, my res is 1920x1080:

##########################

x

##########################
(doesn’t show, basically upper left)

But instead it ends up there:

##########################

x

##########################
(doesn’t show, basically lower right)

Is that expected behavior?

How are you using the camera exactly? And maybe share a screenshot so we can get a clearer picture of what’s going wrong.

I’m simply applying the new Vector through the move method. Moving the camera works fine. The problem is that the game STARTS out like that:

As you can see, I am showing the coordinates, the upper ones are the screen coordinates, the lower ones the logical position, so they are the same.

okay. I am drawing it like this:

- spriteBatch.Begin(SpriteSortMode.BackToFront,
_ null, null, null, null, null,

_ cam.Get_transformation(GraphicsDevice));_

_ foreach (Unit u in game_manager.unit_list)_
_ {_
_ _
_ u.Draw();_ ===> at Vector2(400,400)
_ }_
- spriteBatch.End();

Test-wise the unit is supposed to appear at X400, Y400 and since the camera has not moved game position and screen position should be congruent. I’m wondering, previously I was using Monkey X and it worked fine there. I’m just confused… perhaps I am missing something. But there should nothing happen but applying the translate to the logical position to represent it on the screen position… nothing fancy going on :joy:

Here is the calculation of the matrix from the linked code:

     transform = Matrix.CreateTranslation(new Vector3(-pos.X, -pos.Y, 0)) *
                                     Matrix.CreateRotationZ(Rotation) *
                                     Matrix.CreateScale(new Vector3(Zoom, Zoom, 1))* Matrix.CreateTranslation(new Vector3(graphicsDevice.Viewport.Width * 0.5f, graphicsDevice.Viewport.Height * 0.5f, 0));

Is there something wrong with the viewport * 0.5?