Tag Info

New answers tagged

0

If you are creating a 2D game with tiles you can easily implement your own culling which is a lot cheaper since you only itterate over exactly what you need within your tile array. Things you should know: Camera location Viewport width/height Tile width/height Now we can calculate how many tiles should be drawn. Total horizontal tiles on screen = ...


0

Managed to fix this by using Viewports when drawing the Rectangles / Cameras GraphicsDevice.Viewport = new Viewport(_level); spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.PointClamp, null, null, null, _camera.ViewMatrix); DrawLevelTiles(); spriteBatch.End(); GraphicsDevice.Viewport = ...


3

Rotations are extremely order-dependent. Doubly so when you're composing rotations in local space (so the axes you're rotating around are themselves rotating from one frame to the next) As an extreme example, imagine that you start facing z+, and in one frame you pitch (x rotation) 90 degrees up. In the next frame, you yaw (y rotation) 90 degrees left. ...


1

Adding to what Erez said, you can make any game without using a Viewport and just scaling your textures to a fraction of the screen size, but most of the time using a Viewport is a better option because it scales everything for you. Although you can use any measurement for the game width and height, I like to choose a target resolution for my game ...


1

DMGregory posted this and I'm just copying his comment to be able to close this question with an answer. You're rotating with respect to Space.World. So if your camera's z-axis is pointing along the world x-axis, then what you're applying as a pitch (world x-axist rotation) will be observed as a roll (local z-axis rotation). Does the problem ...


1

The reason for you getting a black screen when you put the camera inside the cube is most likely back face culling. Try calling: glDisable(GL_CULL_FACE); In the beginning of your display function or in main (after enabling depth test) to disable back face culling. If that is helpful you can either change the winding order of your polygons or change ...


0

You will probably find that what is happening is that the camera object is being rotated by Unity as you translate it. I myself have had this happen where I wanted to rotate around a point, but because the camera was angled down, it would roll as it moved sideways. The best way I found to fix this issue, was to reset the pitch of the camera to look towards ...


3

I wrote a camera script that auto-zooms based on a transform's position and scale. Attach the script below to your Camera. Then, create a GameObject, and set its position and size. Then link this gameobject to the "Area" public property of this camera script. The "Area" GameObject can be adjusted at runtime, and should provide you with a mechanism to at ...


4

Normalization The best option would probably be to normalize the data. This can easily be done using the formula: x = a + (X - A) * (b - a) / (B - A) where a and b are the minimum and maximum values for your desired range, respectively; A and B are the minimum and maximum values for your original range, respectively; X is the input value (in your case, ...


0

In AS3, the correct and quick solution would be to alter the projection matrix. Beware, culling will stop working correctly and should be disabled. rx,ry is zoom-rectangle's center, rw,rh width and height. const viewPort:Rectangle = (this.scene).viewPort; const viewWidth:Number = viewPort.width; const viewHeight:Number = viewPort.height; ...


0

Well, that is the mathematical reason why it's problematic, but I'd prefer an analytical explanation. A LookAt(pos, look, up) transform (you call it "cameraposition") is meant to represent a camera located at pos, pointing at look. However, with just pos and look, there are an infinite amount of possibilities for your camera, as you rotate it through the ...


0

You might be able to determine the angle between the player's forward direction and the camera's forward direction and add that amount to playerFacingDirection. float angleToAddToPlayerFacingDirection(Matrix view, Matrix playerFacingMatrix) { Matrix camWorld = Matrix.Invert(view); Vector3 camForward = camWorld.Forward; camForward.Y = 0; ...


0

In case someone stumbles on the same rare and weird issue, I would like to recommend a solution: Decrease your total overall world size. I have figuratively multiplied my whole unity world by 1 / 100 and the issue vanished.



Top 50 recent answers are included