Search Unity

SpriteTile, a fast dynamic tile system (RELEASED)

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

  1. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    Tile.SetColliderLayer.

    --Eric
     
  2. Skullbot

    Skullbot

    Joined:
    Jul 12, 2014
    Posts:
    15
    I just bought this and finally, I found an easy to use map editor for 2D games.

    Just one question, is there a way to add 3D colliders to the tiles ? It's mainly for particles collisions.
    I have to add them by hand right now, so that feature would be cool. (Until particles can collide with Collider2D)
    Game's logic uses physics 2D colliders (generated by SpriteTile), but particle system (here, rain) doesn't.

    I added a mesh renderer here for explanation purpose, but it's only a box collider.

     
  3. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    Hi, there isn't currently a way to add 3D colliders, sorry. It's not something I thought about before, but I'll see if there's a way to do that.

    --Eric
     
  4. Skullbot

    Skullbot

    Joined:
    Jul 12, 2014
    Posts:
    15
    Glad to hear that !
    I looked a bit into the source but I'm not good enough to figure out how to make 3D Collider out of 2D collider bounds.
    Anyway, thanks for the fast reply ;)
     
  5. Eric-Gu

    Eric-Gu

    Joined:
    Feb 19, 2014
    Posts:
    28
    Excuse me. Could I load a new level with fading out and fading in effect?
     
  6. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    Yes; probably the simplest way is to have a texture that covers the screen, which you fade in and out as needed.

    --Eric
     
  7. Vercinus

    Vercinus

    Joined:
    Mar 12, 2015
    Posts:
    2
    It is probably issue with newest unity but after updating it from 5.0.2 to 5.1.1 i cant create new tile sets.
    When i try to import sprites i get this message:"No sprite found for assest xyz. If that's a texture, the texture type needs to be set to 'Sprite' or 'Advanced' with sprite Mode as single or multiple'
     

    Attached Files:

  8. blizzy

    blizzy

    Joined:
    Apr 27, 2014
    Posts:
    775
    I had the same error with one of my sprites, which, interestingly enough, was in a different set before I removed it. I fixed it by duplicating the sprite, then adding the duplicate instead. The sprite itself had not changed since I've added it to the first set.

    And, yes, the sprite was set to Advanced with Sprite/Single.
     
  9. blizzy

    blizzy

    Joined:
    Apr 27, 2014
    Posts:
    775
    Hmm, I'm now getting the same error again with a multi-sprite asset. I've been able to add it to a tile set before, then decided to delete the sprites from the set again (which didn't go through with all tiles, but that's another error.) Then, when I wanted to add the sprites again, that error occured, and it doesn't want to add the sprites anymore. The sprite atlas itself did not change inbetween.
     
  10. blizzy

    blizzy

    Joined:
    Apr 27, 2014
    Posts:
    775
    I seem to have fixed it in SpriteTile's code. Not sure if it is okay to post details here, so I'll send that to Eric directly.
     
  11. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    It's fine to post the code changes here. (This is a good example of not relying on undocumented behavior even if it "always" works. ;) ::slaps self:: )

    --Eric
     
  12. Velcrohead

    Velcrohead

    Joined:
    Apr 26, 2014
    Posts:
    78
    Hi, really interested in buying this. I am more focused on the procedural generation aspect though.

    Does this asset have any support for autotiling / blending between tiles?

    How robust is the API for proc gen, if you don't mind me asking?
     
  13. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    You can set up terrain groups for auto tiling, yes. Pretty much everything can be done with the API; see the docs and reference guides linked near the bottom of this page.

    --Eric
     
  14. blizzy

    blizzy

    Joined:
    Apr 27, 2014
    Posts:
    775
    Would it be possible to change it so that the tiles marked in red can be different than the ones in blue? My tile set has different sprites for these, and right now I would have to correct them manually or programmatically.



    Edit: Ah. Actually my situation is a little different. The red tiles need to be the same as the blue ones. But when I have something like this:



    then the red tile needs to be different than the blue ones.

    So I guess I have a need for different layouts of terrain groups.
     
    Last edited: Jun 23, 2015
  15. blizzy

    blizzy

    Joined:
    Apr 27, 2014
    Posts:
    775
    What to do with sprites that are smaller than your regular tile's size? For example, my tiles are 128x128, and then I have a small sprite that is smaller than that:



    Ideally, I'd like to keep the settings of all layers the same. What I'd like for SpriteTile is to use the actual pivot of the sprite to position it. In the example, I'd set the pivot of the mushroom at the bottom of the sprite, and SpriteTile would position it so that it touches the grass.
     
  16. Skullbot

    Skullbot

    Joined:
    Jul 12, 2014
    Posts:
    15
    You can move down your sprite position by the half of your tile size (64 pixels here) directly on your tileset/spritesheet.

    By the way, doing my 2D Raycast physics, something went through my mind :
    Is there a way, without a per-tile movement, to get the Tile you are standing on ?
    As the colliders are not set per-tile, getting the tile from the collider the gravity Raycast touched is impossible.

    Another little thing, slopes tiles "auto" collisions are a bit weird.
    One tile pixel is 0.01 unit (background is resized x2), tileset is 16x16 pixels, so one tile is 0.16 unit wide.
    Is it because it's too small for precise collisions calculation ? Of course I can still set the collider manually, but still.

    Unity 2015-06-24 00-20-10-91.png
     
  17. blizzy

    blizzy

    Joined:
    Apr 27, 2014
    Posts:
    775
    I see, but that's still not quite the same as positioning it using the pivot I've set in Unity's sprite editor. Also, moving by half the sprite size is not enough for some small sprites.
     
    Last edited: Jun 24, 2015
  18. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    It's possible to edit the source code to create your own terrain groups, since it's mostly data driven, i.e. a matter of changing values in arrays. There are some posts discussing that earlier in the topic.

    As for positioning small sprites, moving the sprite pivot appropriately (in this case, up) will allow you to position it as you like.

    GetTile takes a Vector2 or Vector3 in addition to Int2, so you can use world space coords.

    Probably; I'd try to make it larger, so one tile is 1 unit wide. SpriteTile uses whatever Unity does to create auto colliders, and it seems to work better with larger sprites.

    --Eric
     
  19. blizzy

    blizzy

    Joined:
    Apr 27, 2014
    Posts:
    775
    Duh. I've just learned that Unity actually allows moving the pivot outside of the sprite boundaries. Haven't tested yet, but I just assume that works as expected. Still, it doesn't feel very natural, and also seems like unnecessary work (carefully adjusting the pivot until it looks good.) I'd rather be able to set the pivot to the bottom of the sprite, then have SpriteTile do the rest by snapping the sprite to the cell's bottom.
     
  20. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    That's a good point, but since the pivot (as you note) can be anywhere, that makes things not very straightforward as to what the behavior should be. For myself, rather than eyeballing it, I use math, although that's less effective if you have weird tile sizes. I have been thinking it might be worthwhile having the ability to set the pivot in the TileEditor.

    --Eric
     
  21. Skullbot

    Skullbot

    Joined:
    Jul 12, 2014
    Posts:
    15
    I resized the sprites so 1 pixel = 1 world unit, and collision are way better.
    Still not perfect for slopes though, but as you said it's Unity doing it wrong.
    As I make a platformer, my character origin is perfectly between two tile ... but I assume I can negate 1 from Y component of the vector to get the tile under the player (yeah, this was question + self answer ahah)

    One more question, if I make some tiles somehow destructible, the collisions will update automagically ?
     
  22. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    Not currently, but that's on the to-do list (along with updating the colliders when rotating tiles).

    --Eric
     
  23. Vercinus

    Vercinus

    Joined:
    Mar 12, 2015
    Posts:
    2
    So can you tell when it will be fixed? in new version 2.11?
     
  24. Skullbot

    Skullbot

    Joined:
    Jul 12, 2014
    Posts:
    15
    Small issue :
    The collision color selector doesn't work (color don't update after closing the window) if your cursor is over the SpriteTile editor. (Even if the map editor is behind the color window).
    Color picker on the right of the color box works, but you can select a tile's color with it, but it's probably the same issue.

    The map editor seems to get the cursor focus, which causes some problems.
    Same thing happens if you move your cursor out of the map editor bounds while left-clicking.
    The editor won't register the mouse button release if the cursor is not over it (which allows you to paint without pressing the button).
    Same goes for right click not updating if cursor goes out of bounds during selection.
     
  25. Nixaan

    Nixaan

    Joined:
    May 30, 2013
    Posts:
    118
    If you want i can give you the source changes that replace "terrain group" with the classical 47 tiles set.

     
    AndyGFX likes this.
  26. blizzy

    blizzy

    Joined:
    Apr 27, 2014
    Posts:
    775
    Heh, thanks, I'm fine :) That surely looks interesting, though.
     
  27. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    In version 2.10.1, which is available just about...wait...almost...now!

    SpriteTile 2.10.1

    TileEditor changes:
    • Tiled file importing supports tile flipping and rotation.

    TileEditor fixes:
    • Improved robustness of loading sprites in order to work properly with Unity 5.1.

    I don't have any problems with the color selector being over the editor, but I'm using OS X so I don't know if that's different for Windows. The focus issues are how Unity handles windows, so I'm not sure there's much I can do about that, unfortunately.

    --Eric
     
  28. atsiitech

    atsiitech

    Joined:
    Apr 11, 2014
    Posts:
    7
    This is a great piece of software here. I have only one question, where can I find the 'import' button for Tiled Maps? It's not anywhere on the editor. I have version 2.10 (Unity Store version).

    Edit:

    Found it. I messed the update process so it didn't show. :p
     
    Last edited: Jun 25, 2015
  29. Velcrohead

    Velcrohead

    Joined:
    Apr 26, 2014
    Posts:
    78
    Hello again mate,
    Very happy with my purchase thus far. have briefly read through the documentation and haven't found anything on this yet.

    Is it possible to avoid setting dimensions for the level, and instead constantly generate terrain as the player moves along (aka unlimited world size).

    Thank you.
     
  30. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    No, it's necessary to set the dimensions of the level. You wouldn't want to continuously move in one direction forever anyway, because of floating-point limitations, so I'd suggest that after moving a set distance, you reset the player back to the beginning. You can use that along with the block copy functions to make it look like the world is endless.

    --Eric
     
  31. blizzy

    blizzy

    Joined:
    Apr 27, 2014
    Posts:
    775
    Perhaps there could be a way to hook into the collider creation. This could be useful to add platform effectors, or to create edge colliders instead of box colliders (or whatever SpriteTile is currently using, I haven't checked.)
     
  32. Nixaan

    Nixaan

    Joined:
    May 30, 2013
    Posts:
    118
    Hi,
    Is there a way to scale the whole level - sprites, 2d colliders and cell size all together?
     
  33. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    No, although wouldn't zooming the camera/changing the orthographic camera size basically accomplish that?

    --Eric
     
  34. Nixaan

    Nixaan

    Joined:
    May 30, 2013
    Posts:
    118
    My idea was to try different level sizes in relation to characters (player/enemies) and their "hand made physics". I can achieve it the other way around but it requires fitting numbers to preserve their current movement behavior.

    BTW It would be great if SpriteTile could place prefabs on the grid. It would effectively turn SpriteTile from tile editor into level editor.
     
  35. blizzy

    blizzy

    Joined:
    Apr 27, 2014
    Posts:
    775
    You can work around the current implementation by placing marker tiles in the level. Actually this is even more flexible because it is not limited to prefabs, but you can simply do anything with those markers.
     
  36. atsiitech

    atsiitech

    Joined:
    Apr 11, 2014
    Posts:
    7
    Not sure why I can't get the new version to work (2.10.1) with Unity v5.1.1f1

    on Mac OSX 10.10.3.

    Happens when trying to load tiles, either from folder or sprite.

    MissingMethodException: Method not found: 'System.Type.op_Equality'.
    TileControls.LoadSprite (Boolean replace)
    TileControls.TileSetControls ()
    TileEditor.OnGUI ()
    System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at /Users/builduser/buildslave/mono-runtime-and-classlibs/build/mcs/class/corlib/System.Reflection/MonoMethod.cs:222)

    Edit:

    Solved this by using the source package as suggested earlier in this thread. However, the shader/materials seem to be broken(?) because when I use them on the tiles, it only displays purplish color.
     
    Last edited: Jul 1, 2015
  37. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    Sorry about that; it was an issue with the DLL, so 2.10.2 is out now, which fixes that. I'm not able to find any issues with using the materials, though.

    SpriteTile 2.10.2

    TileEditor fixes:
    • Sprite importing works when using the DLL.

    --Eric
     
    atsiitech likes this.
  38. atsiitech

    atsiitech

    Joined:
    Apr 11, 2014
    Posts:
    7
    Wow that's fast fix, great!

    The material issue is probably my project, I think it got corrupted at some point while updating multiple plugins.
     
  39. blizzy

    blizzy

    Joined:
    Apr 27, 2014
    Posts:
    775
    Would it be possible to add a new method Tile.SetTileMaterial(int layer, Material material) to set the material for the whole layer instead of going through each individual cell? I've added this locally and it speeds things up considerably (4 msec instead of ~10 sec.)
     
  40. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    You can use SetTileMaterial (Material material) to set the material for all tiles, but yes I can add an override for the layer too.

    --Eric
     
  41. blizzy

    blizzy

    Joined:
    Apr 27, 2014
    Posts:
    775
    Sweet, thanks. I'm using SetTileMaterial(Material) already, but I need one of my layers to use a different material.
     
  42. Eric-Gu

    Eric-Gu

    Joined:
    Feb 19, 2014
    Posts:
    28
    Excuse me. Could I unload the current level from the scene? That's means I want to erase the level from the screen.
    Thans!
     
  43. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    Tile.EraseLevel.

    --Eric
     
  44. JimMakesGames

    JimMakesGames

    Joined:
    Nov 13, 2013
    Posts:
    21
    Sorry if this has been asked already (lots of pages on this thread), but I'm considering getting this for a tile based tactical RPG and I was wondering if this would work well with a fog of war type thing. Could I do raycasts to tiles near the player characters to determine which tiles were visible and hide or show them as appropriate? Basically I need to know if there is a collider or something that will let me raycast to a tile. Thanks.
     
  45. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    You wouldn't use raycasting, at least not with Unity's Physics.Raycast, but you can use tile functions such as GetCollider or GetTile to get tile info for specific tiles as needed. But yes you can make fog of war.

    --Eric
     
  46. JimMakesGames

    JimMakesGames

    Joined:
    Nov 13, 2013
    Posts:
    21
    I'm not sure how I'd do it without raycasting. Wouldn't I need to cast to every tile within vision radius in order to see if something is blocking the line of sight? I don't want tiles on the other side of walls to show up.
     
  47. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    You can use the tile functions I mentioned to do tile-based raycasting. If you need some help with that, look up the Bresenham algorithm; also the SetTileLine function in the TileEditor script has a tile-based line function.

    --Eric
     
  48. JimMakesGames

    JimMakesGames

    Joined:
    Nov 13, 2013
    Posts:
    21
    I decided to get it and give it a try, but I think I must be doing something fundamentally wrong. I've made a quick test level in the editor, saved it, and used the code given in the documentation to load it, but I get no level. This is what I see:
    http://i.imgur.com/1rPsRxu.png

    My code is exactly as it is in the documentation, and I've assigned the level file in the inspector. The level is definitely saved because I can load it up in the editor. What am I missing?

    EDIT: I figured it out. Seems that having the pixels per unit set to 1 in the import settings was causing the problem. Not sure why but I changed it and it works now. Thanks for your previous reply, I'll look into that algorithm.

    EDIT 2: Now it isn't working again. It works in the test project I set up, but not when trying to get it working in my existing project. I have no idea why. Everything seems to be the same. I know it's pretty much impossible to answer this sort of problem. I'm just at a loss. I guess I'll keep hitting my head against it.

    EDIT 3: Okay I finally actually really figured it out this time. It was because the camera wasn't aimed at the tiles. I was looking for the tiles to appear in the hierarchy, but I didn't realise they won't appear until they actually enter the field of view of a camera. Now it works without a problem.
     
    Last edited: Jul 8, 2015
  49. blizzy

    blizzy

    Joined:
    Apr 27, 2014
    Posts:
    775
    1 pixel is way too low. You'll run out of floating point space quickly.
     
  50. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    In general I'd recommend a value that makes your tiles be somewhere around 1 unit.

    --Eric