Search Unity

  1. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

SpriteTile, a fast dynamic tile system (RELEASED)

Discussion in 'Assets and Asset Store' started by Eric5h5, Dec 11, 2013.

  1. sygaki786

    sygaki786

    Joined:
    Jan 26, 2014
    Posts:
    142
    Never mind. After applying the prefab, there is a check mark to the extreme right, which I forgot to apply. It works now.

    Also, I have a bunch of crate prefabs. Instead of having a collider for each of them, I would like to put 4-5 crate prefabs together and have an edge collider for all of them combined. What is the most efficient way to accomplish this? I am going to check the tag of the individual crates in Collision Enter which would be 'Crate'. But for the colliders I think it will be more efficient to do this as an Edge for the set of crates, rather than each having its own collider?

    Thanks,
    Arshad
     
  2. sygaki786

    sygaki786

    Joined:
    Jan 26, 2014
    Posts:
    142
    I think I have most of my work that I need to do covered with this tool. One thing, the tiles for the ground are painted into 32*32 tiles. I have a bunch of crates which are 20*20. If I place them in the Tiles in the map, they will be positioned in the Center. Even if I change the pivot point, they would all be changed and wouldn't be able to be beside each other. Is the only option to do this through the Unity Editor? If so how does that work? Since the whole level is loaded at run time through script, how do I add the Crate prefabs in the Unity Editor?

    Thanks,
    Arshad
     
  3. vonchor

    vonchor

    Joined:
    Jun 30, 2009
    Posts:
    68
    Well, I can answer my own question. It appears to work. I dropped all the sprites for Gem Hunt into an atlas and the little game runs. I set the compression to the most awful setting and that propagated into really ugly sprites when running the game.

    Whether the entire API and tile editor is 100% OK remains to be seen though.
     
  4. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,249
    I haven't tried with Unity2017 yet, but if there are any updates required, I'll make sure it works.

    Please do not post assets publicly. That's a copyright violation.

    You could make another layer, and put the crates on the new layer, although lining them up properly would take some fiddling. Maybe easiest just to have the crates in the scene and not part of the SpriteTile level (use the preview function in the TileEditor to position them).

    --Eric
     
  5. spryx

    spryx

    Joined:
    Jul 23, 2013
    Posts:
    482
    Quick question: Is there a way that a single light can affect multiple layers?
    The problem i'm experiencing is that some of my wall tiles need to be on a second layer (so that a floor is beneath them). The only way I can light both the floor and walls is to duplicate lights on multiple layers. This is even more apparent when I have colliders on multiple layers.
     
  6. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,249
    I hadn't thought of having lights affect multiple layers. It seems feasible to add that, although I'm not quite sure what you're referring to regarding colliders on multiple layers. In any case thanks for the idea!

    --Eric
     
  7. spryx

    spryx

    Joined:
    Jul 23, 2013
    Posts:
    482
    Am I incorrect on the collider issue (you can apply a non-physics collider to tiles on different layers, aka per-layer colliders)?

    This also makes shadow casting difficult, because it needs to work on multiple layers in some instances (for instance, if I have actors on one layer, walls on another, and the floor on yet another).

    Ideally, I want my player actor to carry a torch that will cast shadows on other actors, walls, and the floor itself.
     
  8. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,249
    That's correct about colliders. You're saying you want to have the lighting/shadows from a light on one layer be applied to all layers, I take it (ignoring colliders on other layers)?

    --Eric
     
  9. spryx

    spryx

    Joined:
    Jul 23, 2013
    Posts:
    482
    Yes, but the lighting should be applied to multiple layers and respect colliders on those layers (for shadowing).

    If I have floors on layer 0, walls on layer 1, and columns on layer 2 with colliders on both walls (l 1) and columns (l2), the lighting and shadowing should be applied to all 3 layers and utilize colliders on all 3 layers for shadowing.

    I will try to post a picture later of what I intend.
     
  10. spryx

    spryx

    Joined:
    Jul 23, 2013
    Posts:
    482
    Capture.PNG
     
  11. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,249
    OK, I see what you're saying; thank you for the screenshot.

    --Eric
     
  12. kd5crs

    kd5crs

    Joined:
    May 27, 2012
    Posts:
    6
    Hello! I have a question about overlapping tiles. In my game, the player flies a spaceship in a 2D scene (just a skybox for background, no tiles). When you land on a planet, it switches to a SpriteTile scene. I want to be able to see the spaceship on the landing pad in the SpriteTile scene. The ship will be quite large compared to the player.

    I've added the spaceship sprite to the tileset, and can add it to the map with no problem. It looks great! However, the ship only shows when the anchor tile is visible. That makes sense, but it isn't what I want.

    Is there a way to make an overlapping tile sprite always show such that the camera will see it even if the anchor tile is offscreen? There would only be 5 or so ships like that on a given map, so it is ok if it uses more memory/computing power than the standard super-leaness that SpriteTile provides.

    The ship is surrounded by collider tiles, so it isn't important that the giant tile act solid or anything. I just want a way that doesn't require me to "draw" each ship into the SpriteTile map. I want to just place the sprite and done.

    Thanks.
     
  13. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,249
    Yes, if you increase the "add border" value for a layer, then more tiles are rendered outside the camera view, so you can have oversized tiles without the pop-in effect.

    --Eric
     
  14. gamedevluuk

    gamedevluuk

    Joined:
    Jun 23, 2014
    Posts:
    11
    Hiya @Eric5h5!

    Quick little question: We have our own level editor / tile system and format. However our system takes up a lot of performance so was wondering if it would be doable to use just parts of your solution. I don't want to rewrite the level editor for example.

    Thanks!
    L
     
  15. orb

    orb

    Joined:
    Nov 24, 2010
    Posts:
    2,960
    Building a map from your own loader shouldn't be hard. The API has what you need to procedurally generate maps, and this is pretty much the same.
     
  16. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,249
    Yes, you can probably alter your level editor to use the SpriteTile API, and the file format specs are here.

    --Eric
     
  17. jimmy14mac

    jimmy14mac

    Joined:
    Dec 8, 2013
    Posts:
    6
    I'm interested in using SpriteTile to make a 2D game where the player can dynamically manipulate the Tilemap and place objects. How well-geared is the API towards accomplishing this? :D
     
  18. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,249
    It's heavily geared toward that, actually; see the docs linked to on the SpriteTile page. Thank you for your interest!

    --Eric
     
  19. jimmy14mac

    jimmy14mac

    Joined:
    Dec 8, 2013
    Posts:
    6
    Awesome! I will take a look. :)
     
  20. DreamPower

    DreamPower

    Joined:
    Apr 2, 2017
    Posts:
    86
    The documentation for switching from DLL to Source Code seems to be out of date, or I've got other problems. It says:

    But, I don't have a SpriteTile/Resources folder, nor a TileManager object, and that doesn't appear to be part of the full package nor the source package. And after deleting all the DLLs in the Plugins folder (as per instructions), I no longer have a Tile Editor - in the SpriteTile/Editor folder there's a text file saying that if you want that source code to contact the developer, so it apparently still needs that .DLL at least, except that I added just that .DLL back and when I try to open the SpriteTile Editor I get "BadImageFormatException: Could not resolve field token 0x0400000b".

    Also, when I run my game I now have a lot of errors. Example:

    Note, after returning to a fully .DLL setup, everything works and is happy once more, after re-loading up my tiles.
     
    Last edited: Aug 20, 2017
  21. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,249
    I've updated the docs for the next version:

    1) Remove the two SpriteTile DLLs that are in the Plugins/SpriteTile folder.

    2) Add the source code.

    3) On the Plugins/SpriteTile/Resources/TileManager object, the TileManager reference will now be missing. Replace it with the TileManager script that you just added (by using drag’n’drop or using the script selector and choosing TileManager). Your data will not be lost when you do this, but make sure you do this step before opening the TileEditor again.

    Although it's basically the same aside from slight differences in folder structure. You do have a TileManager object in the SpriteTile resources folder unless you haven't set up your tile sets. If you want the editor source then please contact me as it says. If you use the source then you can (and need to) remove the DLLs.

    --Eric
     
  22. DreamPower

    DreamPower

    Joined:
    Apr 2, 2017
    Posts:
    86
    Aha, I had deleted the entire plugins/spritetile folder to get rid of all DLL’s to save a couple clicks :) That got rid of my TileManager
     
  23. Prometheusheir

    Prometheusheir

    Joined:
    Aug 15, 2015
    Posts:
    19
    Hi, I have so far used a very old version of SpriteTile I bought directly from your website. I just uploaded to Unity 5.6.3f and Unity now longer shows the SpriteTile Editor as a choice in the WINDOWS menu. I used this opportunity to also buy the asset store version so I can have an easily updated version going forward. How to I make sure the transition for my existing project works fine, can I install the latest asset store SpriteTile into my project or should I remove any DLLs or other old versions first? Thanks!

    update: I managed to follow the latest update instructions, including re-assigning the script to the tile manager. the project/game now works fine again, so that is great. But I still don't have a TileEditor options in the Unity Windows menu. Any help much appreciated.

    aaaaaand... it fixed itself, it reappeared after two Unity restarts. :cool:
     
    Last edited: Aug 21, 2017
  24. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,249
    Hmm, not sure why it would need Unity to restart, but glad you got it sorted. :)

    --Eric
     
  25. Prometheusheir

    Prometheusheir

    Joined:
    Aug 15, 2015
    Posts:
    19
    Question: for my pixel art 2D game I am trying to remove any unnecessary shaders. Profiler tells me there are 21 still used, and they seem to be referenced by the SpriteTile Diffuse assets. Are they needed? How can I disable them safely? thanks!
     
  26. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,249
    You can change the materials in SpriteTile/Resources to all use the same shader.

    --Eric
     
  27. Prometheusheir

    Prometheusheir

    Joined:
    Aug 15, 2015
    Posts:
    19
    thanks!
     
  28. codesushi

    codesushi

    Joined:
    Sep 27, 2014
    Posts:
    22
    Hi,

    This is a great engine!

    I am having some trouble with converting to world coordinates. By default, my level renders somewhere offset from Unity's (0, 0) world coordinate.

    I would like to retrieve my level's left/right and top/bottom bounds in Unity's world coordinates, so that I can force my camera into those bounds.

    However, when I try Tile.MapToWorldPosition, I am getting coordinates returned as if each tile is one unit, and without any offset.

    Vector3 worldPos = Tile.MapToWorldPosition (new Int2 (3, 0)); // returns worldPos.x = 3 and worldPos.y = 0

    How can I get the correct units back?
     
  29. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,249
    Hi, MapToWorldPosition includes tile size and layer offset. Do you have multiple layers? If so, perhaps you specified the wrong layer.

    --Eric
     
  30. codesushi

    codesushi

    Joined:
    Sep 27, 2014
    Posts:
    22
    Yes, I have two layers. But I am still seeing the same for both layers:

    Tile.SetCamera ();
    Tile.NewLevel (new Int2 (mapWidth, mapHeight), 0, 1f, 0f, LayerLock.None);
    Tile.AddLayer (new Int2 (mapWidth, mapHeight), 0, 1f, 2f, LayerLock.None);

    Vector3 worldPos = Tile.MapToWorldPosition (new Int2 (3, 0), 0); // returns worldPos.x = 3 and worldPos.y = 0
    worldPos = Tile.MapToWorldPosition (new Int2 (3, 0), 1); // returns worldPos.x = 3 and worldPos.y = 0
     
    Last edited: Sep 19, 2017
  31. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,249
    You have the tile size as 1, so that's correct. If the tile size is 1.0, then there's no difference between map coords and world coords. If you're not using SetLayerPosition, there's no offset.

    --Eric
     
  32. codesushi

    codesushi

    Joined:
    Sep 27, 2014
    Posts:
    22
    But the map is not rendering at x = 0 in Unity's world coordinates. It appears the map's left edge begins around 14 units.

    Also, what should tile size be set to so that it reflects the actual tile dimensions in Unity's world coordinate space?
     
  33. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,249
    Tile size is: "the dimension, in units, of each cell in the level". If tile size is 0.5, then each tile is half a unit. If it's 1.0, then each tile is 1 unit. If it's 2.0, then each tile is 2 units, and so on. So, tile size is already just plain units. A tile at x = 0 starts at x = 0 in world coordinates, unless you move the layer using SetLayerPosition. (Note that tile position is from the tile center. So the left edge of a tile at x = 0, with a centered pivot and a size of 1, would be at x = -0.5. The center of the tile is at x = 0.0.)

    --Eric
     
  34. codesushi

    codesushi

    Joined:
    Sep 27, 2014
    Posts:
    22
    Ah yes, this is correct. The problem I was seeing is that the camera's coordinates don't match up, but that's because the camera's anchor point is in its center.

    Another question: Is it possible to change the tint of tiles at runtime? I am looking to create a "fog of war" type effect, but I don't think I'll be able to use the standard light styles to achieve it.
     
  35. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,249
    Yes, use Tile.SetColor.

    --Eric
     
  36. codesushi

    codesushi

    Joined:
    Sep 27, 2014
    Posts:
    22
    Thanks!

    Regarding fog of war effect. It would be desirable for visible tiles to have blurred edges that blend with hidden. Is this possible using another layer of tiles and setting a blend mode, if one is available?
     
  37. sngdan

    sngdan

    Joined:
    Feb 7, 2014
    Posts:
    1,006
    I don't know, how exactly you would like the effect to look like, but it sounds you might be able to do it without Sprite tile. Have the tiles always visible but cover them up with a black texture that has a transparent "hole" in the middle & move it with the player...(or is it multiplayer, then a bit more complicated)
     
  38. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,249
    Using SpriteTile, a fog of war with blurred edges would be done with another layer. You'd have a set of tiles (bottom edge blurred, right edge blurred, etc.) that you use as appropriate...should be fairly straightforward.

    --Eric
     
  39. Toad

    Toad

    Joined:
    Aug 14, 2010
    Posts:
    297
    Hi Eric

    Please could you have a look at a problem I'm having? I raised a support request via your website a few days ago, but I'm not sure if you got it or not?

    Basically I'm creating levels in code rather than loading pre-designed ones. This works fine with the first level, but when I create a second level I get the following exception;

    ArgumentOutOfRangeException: Argument is out of range.
    Parameter name: index
    System.Collections.Generic.List`1[System.Collections.Generic.List`1[System.Collections.Generic.List`1[UnityEngine.PolygonCollider2D]]].get_Item (Int32 index) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Collections.Generic/List.cs:633)
    SpriteTile.Tile.DeleteLevelColliders ()
    SpriteTile.Tile.DeleteLevelObjects ()
    SpriteTile.Tile.NewLevel (SpriteTile.LevelData[] levelData)
    SpriteTile.Tile.NewLevel (Int2 mapSize, Int32 addBorder, Single tileSize, Single zPosition, LayerLock layerLock)

    I've re-created the error by creating an empty scene with the below script attached to the Main Camera;

    Code (CSharp):
    1. public class NewLevelTest : MonoBehaviour {
    2.  
    3.     // Use this for initialization
    4.     void Start () {
    5.         Tile.SetCamera();
    6.         Tile.NewLevel(new Int2(3, 3), 0, 1f, 0f, LayerLock.None);
    7.         Tile.AddLayer(new Int2(3, 3), 0, 1f, 0f, LayerLock.None);
    8.     }
    9.  
    10.     private void Update()
    11.     {
    12.         if(Input.GetKeyUp(KeyCode.R)){
    13.             Tile.NewLevel(new Int2(3, 3), 0, 1f, 0f, LayerLock.None);
    14.         }
    15.     }
    16. }
    Commenting out the call to Tile.AddLayer() stops the exception being triggered.

    Cheers
    Matt
     
  40. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,249
    I didn't get it, sorry about that.

    Hmm, tried your code here and it works with no errors. What version of SpriteTile are you using?

    --Eric
     
  41. Toad

    Toad

    Joined:
    Aug 14, 2010
    Posts:
    297
    Weird. I'm using SpriteTile 3.1 on Unity 2017.1.2.
     
  42. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,249
    I tried again with 2017.1 and still no errors. The error seems to have something to do with deleting the colliders, but I tried adding some and it works fine. Anything else you can think of that might be involved?

    --Eric
     
  43. Toad

    Toad

    Joined:
    Aug 14, 2010
    Posts:
    297
    I did the following on my Mac;

    Created a new project in Unity.
    Imported SpriteTile from the Asset Store.
    Imported a tileset.
    Opened the Tile Editor window and loaded in the tileset.
    Attached the NewLevelTest script to the main camera and saved the scene.
    Ran the scene.
    Pressed 'R'.
    Got the exception.

    I then repeated the process on my Windows PC and got the same error.
     
    Last edited: Nov 2, 2017
  44. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,249
    Aha, thank you...I figured out what was going on, so a new version is out, and uploaded to the asset store:

    SpriteTile 3.1.1

    Fixes:
    • Fixed error with Tile.NewLevel if AddLayer had been used but no physics colliders.

    TileEditor Improvements:
    • The system beep doesn't play anymore when keyboard shortcuts are used.

    --Eric
     
  45. Toad

    Toad

    Joined:
    Aug 14, 2010
    Posts:
    297
    Brilliant. Thanks for the fix. I'll keep an eye out for the update on the Asset Store.
     
  46. Toad

    Toad

    Joined:
    Aug 14, 2010
    Posts:
    297
    re: TileEditor Improvements:
    • The system beep doesn't play anymore when keyboard shortcuts are used.

    Could you display a message confirming the level has been saved? (e.g. to the console)


    Also, if I re-size the windows in the Tile Editor (e.g. reduce the width of the Level window to increase the width of the Tiles window), and then play the scene, when I stop the scene and go back to the Tile Editor the windows have reverted back to the default sizes.

    Any chance a change could be made to keep the selected Tile Editor window dimensions after playing the scene?
     
    Last edited: Nov 3, 2017
  47. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,249
    The "unsaved level" dot indicator, next to the file name, disappears if the level is saved. The width of the Tiles pane is actually saved in the level, so if you save the level before entering play mode, the width will be restored when the level is reloaded. Personally I mostly keep Auto on for reloading levels, so this has the same effect as keeping the Tiles pane the same size after play mode.

    --Eric
     
  48. JasonBricco

    JasonBricco

    Joined:
    Jul 15, 2013
    Posts:
    936
    Hey there,

    Just a few questions before I buy. I'm considering using this because I'm beyond frustrated with Unity's built in Tilemap system.

    1. How's the performance in general compared to Unity's tilemap system? (If you've tested it at all). By this I mean level load times, general framerate with lots of tiles on screen, and physics. For example performance comparison between this and Unity's TilemapCollider2D + CompositeCollider2D that generates the collider based on the outline of the tiles in the level.

    2. Currently I have a system where I save an ID/rotation for tiles. Is there some way I could write something to convert my saved data to a format that works with SpriteTile? I guess I'm looking for more information on how SpriteTile does map saving, since I'm not super clear on it after reading the documentation.

    3. Does it use any form of save file compression? Tiny file sizes are important for me.

    I think that's all I have for questions at the moment.

    Thanks in advance!
     
  49. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,249
    I haven't made any direct comparisons, but level load times are pretty much instant (custom binary format), framerate is the same as having as many sprites on-screen as there are tiles (so it's good unless you have tiny tiles, also off-screen tiles have no effect on framerate), physics is standard Unity 2D physics performance with polygon colliders, where any tiles with a physics collider are added to the total. Colliders for the entire level are divided into combined blocks for performance reasons (so tiles with physics colliders can be added/deleted at runtime without having to rebuild everything), where it's 5X5 tiles by default though it can be whatever you want.

    I was thinking about a utility that converts Unity tilemaps to SpriteTile tilemaps, though I'm not sure if there would be enough interest in that now that the built-in tilemap exists. As mentioned, the maps are a custom binary format; the specs on are my website, though it's probably easier to re-create from scratch unless you already have a lot done. Level files use LZF compression, and data is 7 bytes per tile usually (more if using certain features), so e.g. a 150x150 level with 3 layers (67,500 tiles total) ends up at around 50-200K or so, depending on the complexity. Thanks for your interest!

    --Eric
     
    JasonBricco likes this.
  50. m_santoro

    m_santoro

    Joined:
    Apr 29, 2017
    Posts:
    3
    I've been using SpriteTile and really like it but I'm having a problem importing .tmx files. The tilemap looks just like it should, but none of the tiles have triggers set, even though all the tiles in the corresponding tileset have trigger values. Is there an extra step I'm missing?
     
unityunity