Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

[Code to Reality Studios] Voxel UV Issues! Need Help!

Discussion in 'Scripting' started by Code to Reality Studios, Oct 7, 2015.

  1. Code to Reality Studios

    Code to Reality Studios

    Joined:
    Aug 25, 2015
    Posts:
    64
    Hello. My name is Andrew and I am the Founder of Code to Reality Studios (c). We are currently working on a 2D open-world survival game such as Terraria or Starbound.

    What I need help on:
    When I generate the chunks for my world and load up the collisions and UV maps, the UVs seem to go over their Uv 'tile' boundaries in the Texture. Here is what it looks like:
    Unity_ForumsScreenshot01.png

    Here is the Texture's properties:
    Unity_ForumsScreenshot02.png

    To generate the UVs I have, in a script called Tile.cs, a function called UV.
    Code (CSharp):
    1. public struct UV { public int x; public int y; }
    2.  
    3.     const float tileSize = 0.25f; //How much space we take out of the tilesheet for our sprite
    4.  
    5. public virtual UV TexturePosition(Solidity solidity)
    6.     {
    7.         UV uv = new UV();
    8.         uv.x = 0;
    9.         uv.y = 0;
    10.  
    11.         return uv;
    12.     }
    And in the, lets say TileGrass.cs, we override the UV mapping for every tile to have their own part of the tilesheet.
    Code (CSharp):
    1. //TileGrass.cs
    2.  
    3. public override UV TexturePosition(Solidity solidity)
    4.     {
    5.         UV tile = new UV();
    6.  
    7.         tile.x = 3;
    8.         tile.y = 0;
    9.  
    10.         return tile;
    11.     }
    Why are the single tile's textures showing part of their surrounding textures in the tilesheet? If anyone can help, it would be most appreciated.
    Thank you!
     
  2. Samuel411

    Samuel411

    Joined:
    Dec 20, 2012
    Posts:
    646
    The sprites are overlapping I believe.
     
  3. Code to Reality Studios

    Code to Reality Studios

    Joined:
    Aug 25, 2015
    Posts:
    64
    They are not and they are not sprites. They are a part of multiple chunks generated by scripts.