Search Unity

Better way to do connected textures?

Discussion in 'Scripting' started by RiokuTheSlayer, Apr 28, 2015.

  1. RiokuTheSlayer

    RiokuTheSlayer

    Joined:
    Aug 22, 2013
    Posts:
    356
    I have a system here that generates some terrain for me, which is all nice and good, but I want to implement connected textures so everything looks nice. Is there a way to do this without checking up,down,left,and right, then going through like 14+ if() statements to get the correct texture for the block?

    Right now it checks the adjacent blocks, sets booleans for each side, true if it matches the current block id, false if it does not. Then I just loop through each possible texture and the booleans that would correctly display that. (I.E. left and right but not up and down would make a sorta - symbol, with grass along the edges.) I just feel like this had to many steps possible to do at once, and would lag the game a lot when generating the world. Right now with no connected textures, it's doing about 30ms for 600x30 blocks.
     
  2. Stef_Morojna

    Stef_Morojna

    Joined:
    Apr 15, 2015
    Posts:
    289
    When you generate the map you can make a loading screen and check up,down,left,and right, then going through like 14+ if()

    And then evry time you break a block update all the blocks around it.