# Tagged Questions

Game worlds are viewed from a camera, which is the viewpoint from which the game world is observed from.

24k views

### How can I orbit a camera about it's target point?

I'm drawing a scene where the camera freely moves about the universe. The camera class keeps track of the view (or look at) point, the position of the camera, and the up vector. These vectors/points ...
7k views

### Implementing a camera / viewport to a 2D game

What is the most practical way to implement camera/viewport to a 2D-game? I've read, that I should store the object world position instead of position relative to the screen? Current situation: I ...
7k views

### Cast ray to select block in voxel game

I am developing a game with a Minecraft-like terrain made out of blocks. Since basic rendering and chunk loading is done now, I want to implement block selecting. Therefore I need to find out what ...
845 views

### How do I keep my character centred on screen?

I am making a game similar to Legend of Zelda: Link to the Past (top-down 2D action-adventure). I want the character to stay centred on the screen when he moves. Currently, whenever the player wants ...
16k views

### How can I convert a mouse click to a ray?

I have a perspective projection. When the user clicks on the screen, I want to compute the ray between the near and far planes that projects from the mouse point, so I can do some ray intersection ...
5k views

### How to avoid gimbal lock

I am trying to write code with rotates an object. I implemented it as: Rotation about X-axis is given by the amount of change in y coordinates of a mouse and Rotation about Y-axis is given by the ...
33k views

### Why do we move the world instead of the camera?

I heard that in an OpenGL game what we do to let the player move is not to move the camera but to move the whole world around. For example here is an extract of this tutorial: OpenGL View matrix ...
12k views

### How to add a scrolling camera to a 2D Java game?

I am attempting to create a game where the camera follows the player, always making sure the player is in the center of the screen. How would I go about this? This game is a 2D Java game, made with no ...
5k views

### Why does Unity in 2d mode employ scaling and the default othographic size the way it does?

I previously used SFML, XNA, Monogame, etc. to create 2d games, where if I display a 100px sprite on the screen, it will take up 100px. If I use 128px tiles to create a background, the first tile will ...
412 views

### How do I ensure that my 2D side-scroller camera stays within the world bounds?

I have tried implementing a basic 2D sidescroller camera in XNA, but I don't want it to be able to scroll past the edges of my tile map! I tried to fix it, but when I get the left side working, the ...
5k views

### Mouse aim in an FPS

I would like to make a First Person Shooter and move the camera with the mouse. The problem is that when the cursor reaches the limits of the screen, the camera won't turn anymore. How can I keep the ...
9k views

### XNA 2d Camera Scrolling - why use matrix transform?

I am making a test game where I want the level to be constantly scrolling. To create this effect I have established a camera class which simply stores a vector2 position and an enum direction. It also ...
5k views

### 3D Camera Rotation

Please, forgive me, but I need help and I've been stuck on this for a few weeks now, I'm making no progress and everywhere I go and I see a different answer, everything I try doesn't work. I've had ...
3k views

### Mouse location is off due to camera

I'm building a top down shooter but I have a little issue with my camera and mouse. When I add the camera that I use to my game (see here) my mouse pointer seems to be in the wrong location. When I ...
4k views

### Orbiting a specific point - Orbiting Camera

How would I create a camera that with the mouse, it allows you to orbit around a specifc position, with the camera always facing that point? I would also like it to be able to always be at a constant ...
186 views

### Why is the camera tilting around the z axis when I only specified x and y?

My goal is to program a camera to point towards the mouse cursor. I attached the following script to the Main Camera. using UnityEngine; using System.Collections; public class CameraController : ...
12k views

### Realistic Camera/Screen Shake from Explosion

I'd like to shake the camera around a bit during an explosion, and I've tried a few different functions for rocking it around, and nothing seems to really give that 'wow, what a bang!' type feeling ...
2k views

### Mega Man-style screen scrolling design

The NES classic Mega Man series uses a very specific scrolling technique that I'm having a hard time wrapping my head around implementing. Essentially, the level is divided into "screens" which are ...
4k views

### How to keep my Quaternion-using FPS camera from tilting and messing up?

I am using an FPS-like camera, and it uses quaternions. But, whenever I try looking up and then sideways, it tilts, and sometimes it can turn upside down. How can I fix this?
3k views

### Viewport / Camera Calculation in 2D Game

we have a 2D game with some sprites and tiles and some kind of camera/viewport, that "moves" around the scene. so far so good, if we wouldn't had some special behaviour for your camera/viewport ...
2k views

### Creating my own kill cam

I plan on creating my own kill cam system for a sandbox tool set. After thinking about the mechanics of the kill cam itself, however, I'm quite lost. I'm trying to recreate the ones commonly seen in ...
7k views

### 3D Ray Casting / Picking

I am not sure if I should post this link, but I feel this falls into game development just as much as it does math. I have a ray cast's far and near values and I am trying to calculate the end point ...
2k views

### How can I track a falling ball with a camera?

I have been trying to get my camera to follow a falling ball but with no success. here is the code float cameraY = (FrustumHeight / 2)+((ball.getPosition().y) /2) - (FrustumHeight /2); ...
2k views

### 2d game view camera zoom, rotation & offset using 'Filter' / 'Shader' processing?

I wish to add the ability to zoom-in, zoom-out, rotate and move the view in a top-down view over a collection of points and lines in a large 2d map. I split the map into a grid so I only need to ...
512 views

### Unity3D Camera constantly moving

I'm trying to make my own first person camera controls in unity that use both thumbsticks on a joypad. I have this working fine. However, when I move the right thumb stick (the one uses to look left / ...
1k views

### Orthographic Camera Zooming

In XNA I am using a spritebatch to render a board. I have created a camera class which can provide me a view and projection matrix. Currently I am supplying the view matrix to my sprite batch when I ...
1k views

### Obtaining a world point from a screen point with an orthographic projection

I assumed this was a straightforward problem but it has been plaguing me for days. I am creating a 2D game with an orthographic camera. I am using a 3D camera rather than just hacking it because I ...
3k views

### Calculating camera frustum planes using existing matrix

I'm trying to get basic frustum culling against an AABB working, and I'm having a bit of trouble figuring out how to extract the frustum planes from my camera's transform matrix. All the example code ...
2k views

### First person camera with Bullet Physics

Before integrating the Bullet Physics, the camera worked fine. But instead of using my own simple struct for transform data, I use rigid body structs provided by the physics library now. There are ...
3k views

### How can I make my player move in the direction the camera faces?

I have a 3rd person camera which can rotate around the player. My problem is that wherever camera is facing, players forward is always the same direction. For example when camera is facing the right ...
313 views

### Keep Mini map static after rotating / zooming with camera

Hi I am making a 2D game, where the Camera is able to rotate / zoom in or out on the camera focus (the player usually). However my game also contains a mini-map, and so far whenever I have to rotate ...
1k views

### Making a Camera look at a target Vector

I have a camera that works as long as its stationary. Now I'm trying to create a child class of that camera class that will look at its target. The new addition to the class is a method called ...
543 views

### CubeRealm OpenGL rotation problems, need help. :\

I'm totally new to OpenGL and I'm working on a Sandbox game called CubeRealm. My problem you see is rotation. I've got it in my head that to rotate the 'camera' I just rotate all the scene by the ...
5k views

### How to blend two cameras when traveling through a portal in Unity3D

Before I get to my question, I know the most obvious solution would be to use the normalized view port rect, however I need more complex shapes than a rectangle, and I've looked in to using the view ...
6k views

### Determine corners of a specific plane in the frustum

I'm working on a game with a 2D view in a 3D world. It's a kind of shoot'em up. I've a spaceship at the center of the screen and i want that ennemies appear at the borders of my window. Now i don't ...
3k views

### What's the best head-bob formula?

Given a point in space, a direction of travel, and a time since start, what's a convincing, non-sickening formula to simulate head bob? What's been successful in previous games? Has there been any ...
5k views

### Why / how does XNA's right-handed coordinate system effect anything if you can specify near/far Z values?

I am told repeatedly that XNA Game Studio uses a right-handed coordinate system, and I understand the difference between a right-handed and left-handed coordinate system. But given that you can use a ...
2k views

### Implementing a camera on HTML5 canvas?

I am trying to work out the best way of implementing a camera in my simple 2d game. The way it is structured at the moment is my game objects all have draw functions, which are passed a canvas ...
3k views

### Camera Control Techniques in Games

I am an MPhil student in Computing Science working on the problem of camera control in graphics. Though the literature of camera control dates back to the end of 1980s, the majority of them (up to my ...
6k views

### How to implement a basic arcball camera in OpenGL with GLM

I only just started learning OpenGL and even things like vector maths etc a couple of days ago, so I am having a bit of trouble figuring out exactly what to do to implement an arcball camera system. ...
479 views

### In a scrolling 2D game, should the objects move or should the camera move?

I'm new to game design and don't really know how things are done. I'm thinking of building an iOS game where a ship has to fly as high up as possible (at variable speeds), collecting power ups, et ...
811 views

### 3D zooming technique to maintain the relative position of an object on screen

Is it possible to zoom to a certain point on screen by modifying the field of view and rotating the view of the camera as to keep that point/object in the same place on screen while zooming ? Changing ...
2k views

### Scrolling 2D sprites on a map with a camera

I'm working on a 2D sprite-based strategy-type game (ok, full disclosure: it's a tower defense game), and I'm having a problem getting the actors to behave correctly when I move the camera. I've got ...
1k views

### XNA Camera 2D confusion

I have followed the tutorial at http://www.david-amador.com/2009/10/xna-camera-2d-with-zoom-and-rotation/ to implement my 2D camera and everything works just fine. However this leaves me confused. ...
102 views

### Zoom Camera from C# in Unity

I am creating endless running game. I want to zoom camera when player dies to the player. I have tried using camera.FieldOfView, but it does not work. Is there another way to zoom In camera to the ...
348 views

### 3d world vertex translation to go to 2d screen coords

My technical english is a little rusty so to avoid misunderstands please be patient with me :) I will try to be brief and clear Situation: - I have a 2d sprite character on the screen - I've just ...
690 views

### Portal Projection

Ok ok I admit, I'm bored and toying with a portal script like the one on steam. I've figured out the following: relative positioning of the mirrored cameras render to texture for the portal (the ...
1k views

### FPS games: don't they have unrealistic one-eyed view? What are the causes?

I have played many fps games, and noticed that the camera perspective is similar to the 'one eyed view' of the surroundings. It does not feel like bilinear. :/ Is it because of the single flat view ...