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
    That's not something I actually know the math for offhand, unfortunately, sorry.

    --Eric
     
  2. rakkarage

    rakkarage

    Joined:
    Feb 3, 2014
    Posts:
    683
  3. PortableCow

    PortableCow

    Joined:
    Dec 31, 2013
    Posts:
    8
  4. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    Use UnityEngine.SceneManager instead.

    --Eric
     
  5. PortableCow

    PortableCow

    Joined:
    Dec 31, 2013
    Posts:
    8
    I'm getting this error:

    Assets/Photon Unity Networking/Plugins/PhotonNetwork/PhotonNetwork.cs(2900,22): error CS0117: `SceneManager' does not contain a definition for `LoadScene'

    In Visual Studio it says, "using directive unnecessary" for this line:

    using UnityEngine.SceneManagement;

    I know this is coming from the PhotonNetwork.cs file but it's not my code and I think there may be a conflict with SceneManager from SpritTile. Do you have any ideas? Thanks.
     
  6. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    In the code, replace LoadScene with UnityEngine.SceneManagement.LoadScene.

    --Eric
     
  7. HYX1337

    HYX1337

    Joined:
    Apr 16, 2016
    Posts:
    2
    Hello,

    I just yesterday bought your plugin and it's amazing! Thank you so much for all the work you put into it! It makes making 2D games a ton of fun :)

    I do have a couple of questions though! No matter how much I tweak the camera, I can't quite seem to get it to show the entire map but nothing beyond that. Is there a hidden "fit map to camera size" feature or something like that that I'm missing? :p

    And my last question is how to put gameobjects on my maps, like NPCs. Right now I have to sort of "blindly" move my objects around the scene view until they show up where I want them on the map. Maybe being able to see the level in Scene View would help with this, but I don't know if that's possible?

    Thanks again!
     
  8. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    No hidden feature. ;) Somebody just asked about that; see some messages above. You can use the preview feature in the SpriteTile editor to position GameObjects in the scene view.

    --Eric
     
  9. HYX1337

    HYX1337

    Joined:
    Apr 16, 2016
    Posts:
    2
    Wow, thanks for the fast response!! Being able to preview the level in scene view completely eliminates my problem with tweaking the camera to be just right, since I can see what I'm doing clearly :)
     
  10. Pelican_7

    Pelican_7

    Joined:
    Nov 25, 2014
    Posts:
    190
    Hi all,

    I'm attempting to make a modification to the SpriteTile source code in order to support shadows on sprite tiles.

    However, when removing the SpriteTile.dll and importing the source code package, all my existing tiles that I have setup are lost. I assume this is due to the TileManager data being stored with the dll? Is there a way in which I can grab this data from the dll before deleting it, and copy it over to some directory that SpriteTile will use when operating with the source code package?

    Thanks in advance,
    Andy
     
  11. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    The data isn't stored with the dll; that's not actually possible. See page 2 in the docs for switching from dll to source.

    --Eric
     
  12. Pelican_7

    Pelican_7

    Joined:
    Nov 25, 2014
    Posts:
    190
    Nice one, thanks Eric!
     
  13. nlebedenco

    nlebedenco

    Joined:
    May 12, 2014
    Posts:
    11
    Sure it is a quick workaround but you should really consider defining your classes in your own namespace to avoid these clashes and it costs nothing. Now UnityTestTools also conflict with your package because of the same name clash. This list will only grow...
     
  14. Fariel

    Fariel

    Joined:
    Feb 9, 2013
    Posts:
    29
    Curious question. Would it be possible to replace the physics collider generation with a single (or multiple) edge colliders?

    Ideally, the tile engine would count each collidable tile as a volume, then make a single polygon or edge collider around the entire volume. This way each tile is not getting a collider. It would help to eliminate the "ghost vertex" problem that Box2D has (outlined here: http://box2d.org/manual.pdf Chapter 4, Edge Shapes) where entities moving along a row of colliders (in this case tiles) seem to bounce between some colliders.In theory, it would also reduce the overhead of collision data with a lot of colliders.

    I guess the downside I see is that you couldn't easily generate tiles at runtime, as the colliders would have to be completely regenerated for the entire map. That's not a feature generally needed for 2D platformers, though. so a toggle for "static colliders" would be beneficial. Thoughts?
     
  15. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    Each tile doesn't get its own collider anyway; by default it's 5x5 tile blocks, to avoid unreasonable numbers of GameObjects. You can use SetColliderBlockSize so that it's as big as the entire level, then it will be one collider.

    --Eric
     
  16. Fariel

    Fariel

    Joined:
    Feb 9, 2013
    Posts:
    29
    Are they solid 5x5 blocks, or does it already incorporate the feature I'm requesting?


    *Edit: Nevermind, I found what you mentioned in the documentation. This is why you're my favorite.
     
  17. orb

    orb

    Joined:
    Nov 24, 2010
    Posts:
    3,038
    Is there an update coming with its own namespace? It's currently clashing horribly with the SceneManager in Unity 5.4.0 betas ;)
     
  18. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    Yep.

    --Eric
     
  19. orb

    orb

    Joined:
    Nov 24, 2010
    Posts:
    3,038
    Excellent :)

    Also, a couple of feature request-ish things: I tried searching for any other tile shapes, but couldn't find any mention of hexes. Any plans, timeline if so?

    I bought a tile asset with some nice overlapping buildings and terrain, which means they need to be ordered back to front from the topmost row. Right now I'm just using layers and letting the row number decide what layer to put automated tiles on, but it's clunky editing maps. I'd love to see a mode which expects rows to tower above previous rows, arranging the render order automatically.

    I would hack away at the code to implement something myself, but right now I have enough with trying to prototype some games ;)
     
  20. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    No plan for hexes at this time. You can use the order fill feature to do things like quickly set back to front order by rows:

    Screen Shot 2016-06-27 at 4.20.24 PM.png

    See pages 21/22 in the docs for info on how to use it.

    --Eric
     
  21. orb

    orb

    Joined:
    Nov 24, 2010
    Posts:
    3,038
    Cheers!
     
  22. legendarymaniac

    legendarymaniac

    Joined:
    Jul 3, 2015
    Posts:
    3
    Hello, I currently using the SpriteTile, but if use a single layer well, the use of multiple layers, SpriteTile will never be displayed (Build Android 4.4.2).

    How it would be solved?


     
    Last edited: Jul 1, 2016
  23. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    Is your camera set up to display more than one layer? Does it work in the editor?

    --Eric
     
  24. legendarymaniac

    legendarymaniac

    Joined:
    Jul 3, 2015
    Posts:
    3
    Thank you for your reply.

    It does not work in the editor that multiple layers. But it works in a single layer.

    The following is the camera settings.
     
  25. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    You probably didn't run the Assets/Set SpriteTile Sorting Layer Names menu item.

    --Eric
     
  26. legendarymaniac

    legendarymaniac

    Joined:
    Jul 3, 2015
    Posts:
    3
    I see! Resolution can is likely, thank you!

    It had been overlooked for it is written at the top of the document.
     
  27. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    SpriteTile 2.13 is out! And should be available on the asset store soon.

    Changes:
    • Requires Unity 5.2.2 or newer.
    • Due to improvements in folder handling in Unity 5.2.2, all SpriteTile assets are now located in Plugins/SpriteTile (except for Editor Default Resources, which still can't be moved). If you're upgrading from a previous version, READ THE UPGRADE GUIDE BEFORE DOING ANYTHING ELSE.
    • The SceneManager class is in the SpriteTile namespace, and renamed to TileSceneManager for good measure, so it doesn't need to be disambiguated with UnityEngine.SceneManagement.SceneManager.
    • Files saved with SpriteTile 2.13 are version 3 now. SpriteTile 2.13 will load files from older versions, but older versions will not be able to load files saved with SpriteTile 2.13 or later.

    Additions:
    • Tile.SetLayerMaterial, for setting the sprite material of all tiles in a given layer.

    Fixes:
    • Tile.SetMapTileset works if the layer contains empty tiles.
    • Tile.GrabSprite works with more recent versions of Unity when the specified layer is not 0.
    • Fixed out of range exception that could occur when using Tile.NewLevel with a LevelData[] array.
    • Fixed error that would occur if the number of layers in a level exceeded the number of sorting layers, even if those layers referred to existing sorting layers.
    • Fixed out of range exception that could occur in certain cases when using Tile.CopyGroupToPosition.
    • Flipped tiles using sprites with a pivot other than the center are displayed properly.
    • Physics colliders for tiles using sprites with a pivot other than the center are positioned properly.
    • Setting tile rotation/flip in code when using physics colliders updates the colliders.

    TileEditor changes:
    • Improvements in open/import dialog handling.
    • Previews for standard groups are handled differently, which includes benefits such as much smaller file sizes when saving groups, and previews that are updated if the tiles making up the group have changed. To upgrade old group files, open them in SpriteTile 2.13 and re-save them.

    TileEditor fixes:
    • When importing TMX files, the "Make tiles with the Collider option checked have colliders in the map after import" option works if there are empty tiles in a layer.
    • Fixed potential issue with file name resulting in an error in the path when saving files.
    • The scene preview, when using multiple layers, sets the sorting layer names appropriately.
    • The scene preview shows flipped tiles.
    • Fixed case where non-square tile size maps were not displayed properly after loading a file.


    Here's the relevant part of the upgrade guide. 'Cause it's important, really. :)

    MAKE SURE YOU ARE USING VERSION CONTROL OR AT LEAST HAVE A BACKUP OF YOUR PROJECT! Since Unity 5.2.2 allows it now, some files have been moved in order to consolidate things in the Assets/Plugins folder where possible. Follow these steps to upgrade a project that uses SpriteTile 2.12 or earlier to 2.13:

    1) Make sure the TileEditor window is closed, and import SpriteTile 2.13. Note that some of these steps will likely generate errors, which is fine. They are temporary and can be ignored. Make sure you do not click Play in Unity or use the TileEditor until you have finished all steps.
    2) Move the SpriteTile/Resources/TileManager file to the Plugins/SpriteTile/Resources folder.
    3) If using the dll, delete the Plugins/SpriteTile dll. If using source, delete the scripts in Plugins/SpriteTile.
    4) Delete the SpriteTile/Editor folder and the SpriteTile/Resources folder. Make sure you moved your TileManager file first so it doesn't get deleted!
    5) Find the Plugins/SpriteTile/Resources/TileManager file and click on it. The Script box will say "Missing (Mono Script)". If using the dll, fix this by opening Plugins/SpriteTile/Core/SpriteTile and dragging TileManager onto the Script box on the TileManager file. If using source, open Plugins/SpriteTile/Core and drag the TileManager script onto the Script box.
    6) Find the Plugins/SpriteTile/Resources/DefaultNonTransparent material. Click on it, and in the Shader drop-down menu, select Sprites/Default Non-Transparent. Repeat this for Plugins/SpriteTile/Resources/DiffuseNonTransparent, selecting the Sprites/Diffuse Non-Transparent shader.
    6) You're now done upgrading. You can go to the Console window and click the Clear button to remove any error messages. If these steps were followed correctly, there should be no permanent errors that don't clear.

    --Eric
     
    orb likes this.
  28. Snownova

    Snownova

    Joined:
    Feb 6, 2016
    Posts:
    1
    I have a question, I'm making a game with SpriteTile, but I want it to be moddable, so I want the tileSet for furniture for example to simply be everything in folder X (and it's subfolders preferably) to be collected at runtime so that users can add objects in a finished compiled version of the game. (the data side will be XML's which contain the name of the objects image)

    Is it currently possible to do this in SpriteTile? I haven't been able to find any documentation on creating tileSets and loading images via code.

    Also a second question, with AnimateTile, are there any plans to implement a function that will apply an animation to a single instance of a tile? For example if I want to animate a door opening, I only want that one door to open, not all the doors.
     
  29. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    I'm not sure if that's possible; SpriteTile stores all the tile info in a ScriptableObject, and from the info I found it doesn't seem like that's something that can be changed at runtime, sorry.

    As for animating a single tile, it would make sense to have a built-in function, but it's pretty trivial to make a coroutine for that with the existing API for now:

    Code (csharp):
    1. function AnimateATile (pos : Int2, layer : int, tiles : TileInfo[], loopCount : int, frameTime : float) : IEnumerator {
    2.     var i : int = 0;
    3.     var count : int = 0;
    4.     while (count < loopCount) {
    5.         Tile.SetTile (pos, layer, tiles[i]);
    6.         if (++i == tiles.Length) {
    7.             i = 0;
    8.             count++;
    9.         }
    10.         yield WaitForSeconds (frameTime);
    11.     }
    12. }
    So if your door tiles were in set 0 tiles 10-12, the door was at (25, 30) on layer 1, you wanted it to play once at .25 seconds per frame, then you'd call

    Code (csharp):
    1. StartCoroutine (AnimateATile (Int2(25, 30), 1, [TileInfo(0, 10), TileInfo(0, 11), TileInfo(0, 12)], 1, 0.25));
    By the way, I had a server hiccup recently, so if anyone downloaded recently and got version 2.12, download again and you'll get 2.13; sorry about that.

    --Eric
     
  30. Azaphrael

    Azaphrael

    Joined:
    Nov 17, 2011
    Posts:
    41
    *sees that a new version is out*
    *screams in excitement*
    *reads the changelog*

    Still no support for setting the color of tiles in the editor? o_O

    *is a sad panda* :(

    PS: You do realize that your tile map editor would be the only one out there supporting the tinting of tiles, right? I really don't know what's stopping you. Everything is in place. You have the SetColor function and the tileinfo can hold a color value. It all comes down to just implementing it in the editor.
     
  31. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    Time is the only thing; I wanted to get a version out that has some important updates and not delay it any more than it already was. 2.13 isn't going to be the last version by any means.

    --Eric
     
  32. Azaphrael

    Azaphrael

    Joined:
    Nov 17, 2011
    Posts:
    41
    Don't ya get me wrong here, I love this asset. And I understand you're a busy guy. I was just hoping...
     
  33. siegeon

    siegeon

    Joined:
    Nov 23, 2010
    Posts:
    81
    Does anyone have experience with using Tile.SetMapBlock() and ensuring the collides are used?
     
  34. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    Sorry about that; there's a bug in the SetMapBlock function, where the line near the end that starts "int yEnd = ..." should be:

    Code (csharp):
    1.         int yEnd = Mathf.Min (p.y + mapData.mapSize.y, thisMapData.mapSize.y);
    --Eric
     
  35. siegeon

    siegeon

    Joined:
    Nov 23, 2010
    Posts:
    81
    That did the trick, thank you very much.
     
  36. Stevepunk

    Stevepunk

    Joined:
    Oct 20, 2013
    Posts:
    205
    Does this asset support sprites with normal maps?
     
  37. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    Please see the conversation here.

    --Eric
     
  38. siegeon

    siegeon

    Joined:
    Nov 23, 2010
    Posts:
    81
    Has anyone tackled making a mini map out of the tiles? So far the only process I have found that works is drawing more tiles with a second camera, and showing that cameras view on a render texture. This method does achieve the affect of a mini map, but at the cost of drawing way to many tiles. I really only need to draw the map based on the collides, a black dot if there is one, and nothing if there is not.
     
  39. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    I'd suggest making a texture based on Tile.GetCollider and SetPixel.

    --Eric
     
  40. siegeon

    siegeon

    Joined:
    Nov 23, 2010
    Posts:
    81
    I will give that one a go, thank you for the suggestion.
     
  41. sanpats

    sanpats

    Joined:
    Aug 24, 2011
    Posts:
    343
    My Script box has been grayed out. I can't drag the script into it.

    Edit 1: I solved the problem, but it requires manual editing of TileManager.asset file using text editor to change the script GUID.
     
    Last edited: Jul 29, 2016
  42. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    It would only be grayed out if the reference is intact. Delete the old SpriteTile dll so that the Script box says "Missing (Mono Script)". Then re-establish the reference by dragging the new SpriteTile dll onto the Script box. (No data is lost when doing this, for the record.) Make sure you follow all steps in the upgrade guide.

    --Eric
     
  43. sanpats

    sanpats

    Joined:
    Aug 24, 2011
    Posts:
    343
    I deleted the file and followed every instruction to the letter. The Script box says "Missing (Mono Script)" but grayed out.

    Unity 5.4.0f3 on Mac OS X 10.11.6
     
  44. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    Sorry, I can't reproduce that. (I'm using f1, haven't tried f3 yet.) Does it happen with other scripts? Create a default script, attach it to an object, delete the script. It's greyed out before deleting, but not after.

    Screen Shot 2016-07-29 at 1.03.23 PM.png

    Screen Shot 2016-07-29 at 1.02.11 PM.png

    Update: downloaded f3, still works as expected. Try going back to your pre-upgrade project and go through the upgrade steps again.

    --Eric
     
  45. sanpats

    sanpats

    Joined:
    Aug 24, 2011
    Posts:
    343
    I tested with default script and empty object, but mine the "Missing (Mono Script)" box is greyed out. Do you use f3 on Mac or Windows?

    I think this might be Unity bug, I will report to them.
     
  46. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    On Mac. What happens if you try an earlier version, like 5.3?

    --Eric
     
  47. sanpats

    sanpats

    Joined:
    Aug 24, 2011
    Posts:
    343
    I found the culprit. It's not yours or Unity, but Full Inspector Serializer. Thank you for your assistance.
     
  48. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    OK, good to know.

    --Eric
     
  49. SoftwareGeezers

    SoftwareGeezers

    Joined:
    Jun 22, 2013
    Posts:
    902
    How should one clean up SpriteTile to remove it from the scene? When I return to the menu, SpriteTile objects still exist, and that then messes up the next time the level is loaded.
     
  50. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    You can use Tile.SetLayerActive to disable layers when loading another scene; since they're not active it won't interfere with anything. You can reactivate them later when needed, and call Tile.SetCamera again.

    --Eric