#### Archived

This topic is now archived and is closed to further replies.

# Grid based world - How to handle camera

This topic is 6186 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Let''s say you are building a tile based world. Where you have a grid of tiles that is loaded around the camera. Each tile is 100x100 units... Let''s say the world can be huge like 1000x1000 tiles (or 100000 by 100000 units) (but not all can be loaded at once, only the 10 radius around the camera) is it better to have the camera in direct world space... Meaning between 0 - 100000 units (X/Z). Or is it better to keep the camera in tile space (0 - 100) and you keep which tile you are in X/Z in a short? The reason I am asking is I guess if I leave the camera in that big of a world space, could it become a bit floating point messy where you can get bad precision the farther out you go (towards 100000) But if you do it on a tile space, then you have to make the tiles shift around... Like when camera is greater than 100 units (moving to a new tile), shift all tiles down, then move the camera back 100... Which is the better thing to do?

##### Share on other sites
no need to make it complicated - just keep your camera in world space. Floats are good enough for all coordinates you use, and the float precision does not depend on the absolute value.

- thomas

##### Share on other sites
Unless your world is really massive, I wouldn''t worry. If it''s really incredibly huge, then you may need to use integers to store the current grid cell and floats to store the position relative to the center of that cell. It all depends on the size of your world and the numerical scale of things within your world. If I were you, I''d make sure there was a decent layer of abstraction around the camera so that I could change the representation of the coordinates in case I needed to. I''d just start with floats within that class representing worldspace coordinates.

1. 1
2. 2
Rutin
19
3. 3
khawk
18
4. 4
5. 5
A4L
11

• 12
• 16
• 26
• 10
• 44
• ### Forum Statistics

• Total Topics
633768
• Total Posts
3013743
×