Search Unity

Camera position in 2d

Discussion in '2D' started by steg90, Feb 8, 2016.

  1. steg90

    steg90

    Joined:
    Jan 26, 2016
    Posts:
    93
    Hi,

    I am trying to create a sandbox game like Terraria, here is a screen shot of the version I did in Java using LibGdx, this map can be pretty much infinite and runs 60fps, caves generated using cellular automata and flood fill for water.


    Now, I'm trying to convert this over to Unity. I've so far create one mesh which is 32 quads wide by 20 quads, each quad has it's own u,v texture coordinates, thus when scrolling, we basically just update the u,v coordinates and redraw the mesh. Now I've got this set up in 2D, using perspective projection on the camera, I've positioned the camera at 14,0, -10 and the tiles start to be draw from 0,0 (each quad is 1 wide, 1 high). Running in unity it appears as follows in scene view:



    Now, my idea of scrolling this is to update the camera position, when position of camera x % 32 = 0 we then update the texture coordinates and redraw the mesh, does this sound correct or am I being plain dumb?!

    Thanks for any advice and help, I'm quite new to unity but not to C#.