{"action":"opened","issue":{"url":"https://api.github.com/repos/sharpdx/SharpDX/issues/993","repository_url":"https://api.github.com/repos/sharpdx/SharpDX","labels_url":"https://api.github.com/repos/sharpdx/SharpDX/issues/993/labels{/name}","comments_url":"https://api.github.com/repos/sharpdx/SharpDX/issues/993/comments","events_url":"https://api.github.com/repos/sharpdx/SharpDX/issues/993/events","html_url":"https://github.com/sharpdx/SharpDX/issues/993","id":303030666,"number":993,"title":"Sharpdx Camera not moving","user":{"login":"MazeThePlayer","id":36680914,"avatar_url":"https://avatars2.githubusercontent.com/u/36680914?v=4","gravatar_id":"","url":"https://api.github.com/users/MazeThePlayer","html_url":"https://github.com/MazeThePlayer","followers_url":"https://api.github.com/users/MazeThePlayer/followers","following_url":"https://api.github.com/users/MazeThePlayer/following{/other_user}","gists_url":"https://api.github.com/users/MazeThePlayer/gists{/gist_id}","starred_url":"https://api.github.com/users/MazeThePlayer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MazeThePlayer/subscriptions","organizations_url":"https://api.github.com/users/MazeThePlayer/orgs","repos_url":"https://api.github.com/users/MazeThePlayer/repos","events_url":"https://api.github.com/users/MazeThePlayer/events{/privacy}","received_events_url":"https://api.github.com/users/MazeThePlayer/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-03-07T09:51:24Z","updated_at":"2018-03-07T09:51:24Z","closed_at":null,"author_association":"NONE","body":"I am trying to move the camera along with the player using this code:\r\n`Camera.Position = (Vector2)gameobject.transform.Position;`\r\nThe camera main class is this:\r\n        `public Vector2 Position = new Vector2();`\r\n\r\n        float Rotation = 0;\r\n\r\n        public float Zoom = 1;\r\n\r\n        public int ViewportWidth;\r\n        public int ViewportHeight;\r\n\r\n        public Vector2 ViewportCenter { get { return new Vector2(ViewportWidth * 0.5f, ViewportHeight * 0.5f); } }\r\n\r\n        public Matrix3x2 GetTransform3x2()\r\n        {\r\n            return Translation;\r\n        }\r\n\r\n        private Matrix3x2 Translation\r\n        {\r\n            get\r\n            {\r\n                return Matrix3x2.Translation(-Position.X, -Position.Y) *\r\n                       Matrix3x2.Rotation(Rotation) *\r\n                       Matrix3x2.Scaling(Zoom) *\r\n                       Matrix3x2.Translation(ViewportCenter); ;\r\n            }\r\n        }\r\n\r\n        public void MoveCamera(Vector2 position)\r\n        {\r\n            Vector2 newPosition = Position + position;\r\n            Position = newPosition;\r\n        }\r\n\r\n        public Camera2D(int viewportWidth, int viewportHeight)\r\n        {\r\n            ViewportWidth = viewportWidth;\r\n            ViewportHeight = viewportHeight;\r\n        }\r\nAnd this is the code i use to render everything:\r\n```\r\n        public void DrawGameobjects(Gameobject[] gameObjects)\r\n        {\r\n            foreach (Gameobject Gameobject in gameObjects)\r\n            {\r\n                if (Gameobject.Enabeld == true)\r\n                {\r\n                    foreach (object Component in Gameobject.Components)\r\n                    {\r\n                        //render 2D\r\n                        if (Component is Sprite)\r\n                        {\r\n                            RawMatrix3x2 CurrentTransform = renderTarget.Transform;\r\n                            Sprite NewSprite = Component as Sprite;\r\n\r\n```\r\n                            if (NewSprite.spriteMode == SpriteMode.Multiple)\r\n                            {\r\n                                int SliceIndex = NewSprite.CurrentSlice;\r\n                                Bitmap Texture = Game.bitmapManager.GetTexture(NewSprite.texture.TexturePath);\r\n                                RawRectangleF PositionRectangle = new Rectangle(new Point(0, 0), NewSprite.spriteSlice[SliceIndex].sliceSize).ToRawRectangleF();\r\n                                float Transparency = NewSprite.Transparency;\r\n                                RawRectangleF ImageRectangle = new Rectangle(NewSprite.spriteSlice[SliceIndex].slicePosition, NewSprite.spriteSlice[SliceIndex].sliceSize).ToRawRectangleF();\r\n                                Vector2 NewScale = (Vector2)Gameobject.transform.Scale;\r\n                                Matrix3x2 Translation = Matrix3x2.Translation((Vector2)Gameobject.transform.Position);\r\n                                Matrix3x2 Rotation = Matrix3x2.Rotation(Gameobject.transform.Rotation.X);\r\n                                Matrix3x2 Scale = Matrix3x2.Scaling(new Vector2(Gameobject.transform.Scale.X * NewSprite.PixelPerUnit, Gameobject.transform.Scale.Y * NewSprite.PixelPerUnit));\r\n                                renderTarget.Transform = (Translation * Rotation * Scale).ToRawMatrix3x2();\r\n                                renderTarget.DrawBitmap(Texture, PositionRectangle, Transparency, BitmapInterpolationMode.NearestNeighbor, ImageRectangle);\r\n                                renderTarget.Transform = CurrentTransform;\r\n                            }\r\n                            else\r\n                            {\r\n                                Bitmap Texture = Game.bitmapManager.GetTexture(NewSprite.texture.TexturePath);\r\n                                RawRectangleF PositionRectangle = new Rectangle(new Point(0, 0), new Size(NewSprite.texture.TextureSize * Zoom)).ToRawRectangleF();\r\n                                float Transparency = NewSprite.Transparency;\r\n                                RawRectangleF ImageRectangle = new Rectangle(new Point(0, 0), new Size(NewSprite.texture.TextureSize * Zoom)).ToRawRectangleF();\r\n                                Vector2 NewScale = (Vector2)Gameobject.transform.Scale;\r\n                                Matrix3x2 Translation = Matrix3x2.Translation((Vector2)Gameobject.transform.Position);\r\n                                Matrix3x2 Rotation = Matrix3x2.Rotation(Gameobject.transform.Rotation.X);\r\n                                Matrix3x2 Scale = Matrix3x2.Scaling((Vector2)Gameobject.transform.Scale);\r\n                                renderTarget.Transform = (Translation * Rotation * Scale).ToRawMatrix3x2();\r\n                                renderTarget.DrawBitmap(Texture, PositionRectangle, Transparency, BitmapInterpolationMode.NearestNeighbor, ImageRectangle);\r\n                                renderTarget.Transform = CurrentTransform;\r\n                            }\r\n\r\n                        }\r\n\r\n                        //Render Physics2D\r\n                        if (Component is Physics2D)\r\n                        {\r\n                            Physics2D Physic = Component as Physics2D;\r\n                            SolidColorBrush SolidBrush = new SolidColorBrush(renderTarget, new RawColor4(0.5f,1,1,1));\r\n                            renderTarget.DrawLine(Physic.Points[0].ToRawVector2(), Physic.Points[1].ToRawVector2(), SolidBrush);\r\n                            SolidBrush = new SolidColorBrush(renderTarget, new RawColor4(1, 0.5f, 1, 1));\r\n                            renderTarget.DrawLine(Physic.Points[1].ToRawVector2(), Physic.Points[3].ToRawVector2(), SolidBrush);\r\n                            SolidBrush = new SolidColorBrush(renderTarget, new RawColor4(1, 1, 0.5f, 1));\r\n                            renderTarget.DrawLine(Physic.Points[3].ToRawVector2(), Physic.Points[2].ToRawVector2(), SolidBrush);\r\n                            SolidBrush = new SolidColorBrush(renderTarget, new RawColor4(1, 1, 1, 0.5f));\r\n                            renderTarget.DrawLine(Physic.Points[2].ToRawVector2(), Physic.Points[0].ToRawVector2(), SolidBrush);\r\n                        }\r\n\r\n                        if (Component is Tilemap)\r\n                        {\r\n                            foreach (Tile tile in (Component as Tilemap).ToRenderTiles)\r\n                            {\r\n                                Bitmap Texture = Game.bitmapManager.GetTexture(tile.TileSprite.texture.TexturePath);\r\n                                RawRectangleF PositionRectangle = new Rectangle(new Point(0, 0), tile.Slice.sliceSize).ToRawRectangleF();\r\n                                float Transparency = tile.TileSprite.Transparency;\r\n                                RawRectangleF ImageRectangle = new Rectangle(tile.Slice.slicePosition, tile.Slice.sliceSize).ToRawRectangleF();\r\n                                Vector2 NewScale = (Vector2)Gameobject.transform.Scale;\r\n                                Matrix3x2 Translation = Matrix3x2.Translation(new Vector2(tile.Position.X, tile.Position.Y));\r\n                                Matrix3x2 Rotation = Matrix3x2.Rotation(Gameobject.transform.Rotation.X);\r\n                                Matrix3x2 Scale = Matrix3x2.Scaling(new Vector2(Gameobject.transform.Scale.X * (Component as Tilemap).PixelPerUnit, Gameobject.transform.Scale.Y * (Component as Tilemap).PixelPerUnit));\r\n                                renderTarget.Transform = (Translation * Rotation * Scale).ToRawMatrix3x2();\r\n                                renderTarget.DrawBitmap(Texture, PositionRectangle, Transparency, BitmapInterpolationMode.NearestNeighbor, ImageRectangle);\r\n                            }\r\n                        }\r\n                    }\r\n                }\r\n            }\r\n            renderTarget.Transform = Game.Camera.GetTransform3x2().ToRawMatrix3x2();\r\n        }`\r\nFor some reason putting \r\n`renderTarget.Transform = Game.Camera.GetTransform3x2().ToRawMatrix3x2();`\r\nin the end doesn't seams to be enough to move the camera.\r\nDoes anyone knows why?"}}
{"actor":{"display_login":"MazeThePlayer"}}