Search Unity

2D Top Down View, Background Tiles/Grid

Discussion in '2D' started by Ethanbf3, Dec 27, 2013.

  1. Ethanbf3

    Ethanbf3

    Joined:
    Feb 15, 2012
    Posts:
    153
    Trying to create the backgrounds using a Tile/Grid System. (Simmiler to Engine001 if anyone used it)

    This is where I select a image (A Chair) and place it on the grid.

    Sprites, Plains Quads seem to be popular. I dont want to use many individual shapes because it might lag the game and the scale of the game is equivalent to Pokemon or bigger

    However im willing to accept using 1 or more planes (as they are resizeable and can be massive) providing i can assign specific textures from a texture sheet to a specific area on the plane grid.
     
  2. unitylover

    unitylover

    Joined:
    Jul 6, 2013
    Posts:
    346
    If you don't want to place tiles individually then your only other option is to create your own texture for the background and use that on a quad / plane.
     
  3. wccrawford

    wccrawford

    Joined:
    Sep 30, 2011
    Posts:
    2,039
    Premature optimization is the root of all evil.
     
  4. unitylover

    unitylover

    Joined:
    Jul 6, 2013
    Posts:
    346
    Wiser words have never been spoken.
     
  5. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    Except using individual GameObjects for every tile is 100% guaranteed to not work well, unless the map is quite small. There's premature optimization, and then there's sensible design. You will need to either use the Mesh class to create mesh chunks, or use a pooling system. (*cough*SpriteTile*cough* ;) )

    --Eric
     
  6. Ethanbf3

    Ethanbf3

    Joined:
    Feb 15, 2012
    Posts:
    153
    Thank you Eric!

    Ok so individual GameObjects will not work well, thats the same idea i had for indivigual quads and planes each with one texture each.
    Like i said i would like to use only 1 plane/quad to host textures and the plane/quad will be slit into tiles (10x10 for example) and each tile will host a 32x32px texture.

    What is this Mesh class of what you speak of? Never heard of it...
    [UPDATE]
    ok is this Mesh class basically a mesh that goes over the object to which you can define where the squares, triangles, vertices etc are and withing those shapes made in the mesh, you can fill the spots with a texture, is this correct?
    [UPDATE END]

    I shall check out sprite tile in a moment
    [UPDATE]
    I'd rather not buy software for this project
    [UPDATE END]

    Please dont use the word "Premature"... Inexperienced will do thank you
     
    Last edited: Dec 28, 2013
  7. unitylover

    unitylover

    Joined:
    Jul 6, 2013
    Posts:
    346
    I'll write some performance tests using different tile methods today and report my results.

    Update: I started to experience massive performance decrease when approaching the 500k sprites range. While this might seem high to some, it's really not and Eric is correct about using object pooling. Another option would be to create large chunks of combined background pieces and use those instead of individual ones. It really boils down to how big you plan on making your game world.
     
    Last edited: Dec 28, 2013
  8. Ethanbf3

    Ethanbf3

    Joined:
    Feb 15, 2012
    Posts:
    153
    Thank you for the researth, its better left to the professinals in my opinion (where would a beginer start? X.X)
    Ok um im starting to get lost again (Dyslexia, i hate it...)
    For starters, for the size of the game world, im hoping to make it pretty big, or as big as i can, also i will plan to add extra locations to the game world (open world)

    Im going to start guessing and peiceing things together so i might talk alot of rubbich...

    Ok im getting lost here, theres abit of Jargon here (no offence). From what i understand object pooling is recycling the objects (tiles) to reduce memory. Correct? If so can these be used at the same time? So for instance 100 tiles with textures creating the map at the same time.

    So for Sprites (Object) each with varying textures, that wont work well due to performance issues, so im guessing the best way to get this done is to use all these 500k sprites in a object pool right? thus reducing memory and performance issues.

    So the above is option 1.

    Now option 2.
    "Another option would be to create large chunks of combined background pieces and use those instead of individual ones."
    Um ok so im guessing we are using bigger objects that half the current value of the 500k? If so theres going to be multiple 32px textures on this object?

    Just noticed you iMakeInternet, so im going to have a look at that
     
  9. unitylover

    unitylover

    Joined:
    Jul 6, 2013
    Posts:
    346
    Don't worry about getting flustered or lost, we've all been there. Heck, I still get lost after hours and hours of playing in Unity.

    Object pooling basically limits the amount of gameobjects you have instantiated during run-time. This helps reduce overhead as the game no longer has to worry about creating and positions the other irrelevant gameobjects not yet needed in the scene. It's a real mobile performance booster.

    Allow me to explain my situation and how I resolved it.

    I'm writting some top down RPG learning materials and in the beginning I started out laying individual grass tiles for one of my areas. This quickly became annoying to say the least. I then began creating prefabs of large chunks (5x5, 10x10, etc....) and placing these in the scene. While this made things easier for map creation I realized I was still creating just as many gameobjects as before and wondered if this would end up hurting me in the end. Long story short, I just ended up making similar sized chunks of terrain in Photoshop as one texture and re-importing them as their bigger counterparts and using them instead. What was originally a 10,000 tile grass layer made up of individual grass sprites is now a 1,000 tile ground layer made up of 100 chunks of grass. Sure it's your traditional tile based layer but I gained a mega boost to my performance and map creation time decreased dramatically.

    Now that my fingers have gone numb from typing I think I've made my point. My method may not be the way other people do it, but it works and there is little overhead to worry about. I think if I ever need to expand my world past the point to where performance begins to decrease then I will use Unity Pro's occlusion culling to effectively object pool for me. Who knows what else I'll have to do... we're all learning here.

    I hope this helps! :)
    Mike
     
  10. Ethanbf3

    Ethanbf3

    Joined:
    Feb 15, 2012
    Posts:
    153
    Ahhhhhh Unitylover! Your iMakeInternet Unity - Introduction unity 2d game development was exactly what i was after!!!!

    Im looking on the net, no luck, then try the community and the answer was staring-- Laughing at my face right in front of me! After looking like a complete fool im now going to hack my head of with a meat cleaver!

    Thank you!!!
    Also with the upcoming tutorial, 2D RPG Tutorial Series, from the image, thats what im going for! Looking forward to it!!! Thanks!

    *Adds to favs*
     
    Last edited: Dec 29, 2013