Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

2D Toolkit - 2D in Unity made simple [RELEASED]

Discussion in 'Assets and Asset Store' started by unikronsoftware, Jun 16, 2011.

  1. unikronsoftware

    unikronsoftware

    Joined:
    May 21, 2011
    Posts:
    1,287
    @mickyg - I don't have any set in stone date for it just yet.
    There is a pretty comprehensive manual + walkthrough now. It will be online with the rest of the tk2d docs closer to release.

    What I can say for sure is nothing MAJOR is going to change between now and release, so it is safe to start building up on it if you would like to - we are using it internally for a game now, so it is unlikely a massive amount is going to change.
     
  2. kuricat

    kuricat

    Joined:
    Mar 25, 2013
    Posts:
    5
    Hi, I'm literally two days into Unity and 2D Toolkit as well, so I apologize for this very basic question.

    I followed the documentation on your website and am pretty familiar with creating sprite collections and sprite animations now. I even was able to get the delegates going -- so far so good!

    What I cant wrap my head around is the camera system. I was using the default MainCamera that is available when you first start a new project, but then I noticed that there is a 2D Toolkit camera. I've read the forums and the documentation, but I still don't understand what it is for. In a 2D Toolkit project, am I supposed to delete the MainCamera and exclusively use the 2DToolkit one?

    As an aside, I did try using the 2DToolkit camera (with an iPhone 5 wide preset for dimensions) and I'm able to get sprites to show up on the screen by adding a 2dtkSprite to the Hierarchy. What I'm having trouble with is using my existing code that Instantiated some Prefabs onto the screen.

    I have an Empty GameObject in my hierarchy that I'm using as a GameManager class that I attached some game logic to. Inside this cs file I am instantiating some Prefabs:

    Code (csharp):
    1. public class GameLogic: MonoBehaviour {
    2.    
    3.     public GameObject enemy;
    4.  
    5.         // This was the original vector3 code that worked with the MainCamera.  It didnt work with tk2dCamera
    6.     //public Vector3 enemySpawnSpot = new Vector3(-1,0,0);      
    7.  
    8.         // Then I tries this, thinking that I could use iPhone 5 coordinates (1136x640) to put a sprite somewhere in the screen
    9.         public Vector3 enemySpawnSpot = new Vector3(100, 100, 0);  
    10.  
    11.         void Start () {
    12.         Instantiate(enemy, enemySpawnSpot, transform.rotation);
    13.     }
    14. ....
    15. }
    This is just a snippet of the relevant (I think) code. I've been messing with the Vector3 values, but I simply cant get the Prefab to show up when using the tk2dCamera. I don't know how to use the tk2dCamera and/or why I need to use it at this point. In any case, if I could get any help on how to Instantiate a Prefab correctly with tk2dCamera, that would be excellent! Btw, I did make sure "Use tk2dCamera" in the SpriteCollection that I'm using. Thank you!


    UPDATE! Sorry, please disregard the above. I made a new project and I'm able to instantiate a prefab clone onto the Hierarchy at Vector(x,y,z) position. I'm trying to transform.Translate it now and I can see its X coordinate incrementing in the Inspector, but it doesnt move in the Camera view. This is being done from a script attached to the Prefab.

    Code (csharp):
    1. public class PlayerScript : MonoBehaviour {
    2.  
    3.     // Use this for initialization
    4.     void Start () {
    5.    
    6.     }
    7.    
    8.     // Update is called once per frame
    9.     void Update () {
    10.         Debug.Log ("PLAYER UPDATE");
    11.         gameObject.transform.Translate(Vector3.right * Time.deltaTime * 0.18f);
    12.     }
    13. }
     
    Last edited: Mar 27, 2013
  3. unikronsoftware

    unikronsoftware

    Joined:
    May 21, 2011
    Posts:
    1,287
    You can use any camera you like with tk2d. tk2d doesn't impose or force you to take any particular path.

    The tk2dCamera has pixel sized units, which can be useful in some cases, not so much in others. You're free to choose whatever works best for any particular case. In your case, your sprite translation is really small - 1 unit = 1 pixel, so you're moving it by 0.18 pixels a second, which is really really slow.

    Steps to troubleshoot
    1. Drag the sprite into the viewport and make sure it is visible at 100, 100,0 .
    2. Increase the 0.18 to something like 4 - 10. You should see it move.
     
  4. unikronsoftware

    unikronsoftware

    Joined:
    May 21, 2011
    Posts:
    1,287
  5. celaeno

    celaeno

    Joined:
    Jan 31, 2013
    Posts:
    64
    I have a question about mipmapping.

    I have some 256x256 sprites for a game with a resolution of 1280x720. Now, when I run this thing on an iPhone 3gs with a lower resolution of 480x320, will automatically use a lower resolution sprite from the mipmap?

    So that it will draw less amount of pixels than 256x256 and I don't have to provide extra low resolution sprites in the game?

    Thanks, I'd like to be sure about this.
     
    Last edited: Mar 31, 2013
  6. unikronsoftware

    unikronsoftware

    Joined:
    May 21, 2011
    Posts:
    1,287
    You need to do two things -
    1. You need to turn on mipmaps in your sprite collection settings + commit. Its off by default.
    2. Use qualitysettings to drop quality level so a mip level is dropped.
     
  7. celaeno

    celaeno

    Joined:
    Jan 31, 2013
    Posts:
    64
    Thanks for your answer.

    I can't find a mipmaps setting in the sprite collection, but the sprite atlas texture has turned on "generate mipmaps", actually I thought that was enough?

    Second, I use quality level "good", do I have to drop to "simple"? Or do you mean the texture quality, now it's set to "full resolution".

    But I thought when this 256x256 sprite is drawn on the screen in a square of let's say 16x16 pixels, it automatically uses a lower resolution sprite from the mipmap, so it only draws 16x16 pixels, or do i misunderstand something?
     
  8. unikronsoftware

    unikronsoftware

    Joined:
    May 21, 2011
    Posts:
    1,287
    You're not misunderstanding that. It will use a lower mipmap when drawing 256x256 -> 16x16.
    The QualitySettings thing is to limit how many mips are actually loaded in - to save a bit of memory on the lower resolution hardware.

    Keep in mind that with mips you are likely to get fair bit more artefacts from the atlas. The default sprite collection settings are set up for 1 drop in mip level, but if you want more you will have to pad more, otherwise you will get sprites bleeding across edges.
     
  9. celaeno

    celaeno

    Joined:
    Jan 31, 2013
    Posts:
    64
    Thanks again for help!

    That the default sprite settings are set up for 1 drop in mip level, does that mean that in this case it only has a 256x256 and a 128x128 mip level? When I draw this sprite on a 16x16 square it is not bleeding across the edges.

    Is it the Pad Amount where I can set the amount of mip levels? And I still can't find a turn on mipmap setting in the sprite collection.

    I'm not that worried about memory because a full mipmap only needs 33% more memory. Only thing is that a texture on an iPhone 3gs can't be bigger than 1024x1024. But I thought the mipmap levels aren't generated within the atlas itself, if you understand what i mean?
     
  10. unikronsoftware

    unikronsoftware

    Joined:
    May 21, 2011
    Posts:
    1,287
    You can't set up number of mip levels, just whether there are mips or not.
    You can find this tick box in Sprite Collection Settings > Texture Settrings > Mip Maps. (if you can't see it it means you are on an ancient version of tk2d...)

    Pad amount tells it how many pixels of padding to add around your texture. If you're using mipmaps and want it to scale down without any artefacts you will have to increase this amount by quite a bit.

    Also, the mip map sizes don't count to the max texture size
     
  11. celaeno

    celaeno

    Joined:
    Jan 31, 2013
    Posts:
    64
    Ok that's clear, thanks.

    I'm on Toolkit version 1.7. Do you know if mipmaps are turned on by default on this version? Or is there a way I can test this, because I'd like to be sure about it
     
  12. unikronsoftware

    unikronsoftware

    Joined:
    May 21, 2011
    Posts:
    1,287
    Theyre turned on by default in 1.7. if you wish to turn them off, you'll have to do so manually on the atlas textures in that version.
    1.7 is really old, by the way. We're now on 1.92...
     
  13. celaeno

    celaeno

    Joined:
    Jan 31, 2013
    Posts:
    64
    Nice to hear that mipmaps are turned on :) The old version still runs good, but maybe time to move on to the newer version.
     
    Last edited: Apr 4, 2013
  14. BTStone

    BTStone

    Joined:
    Mar 10, 2012
    Posts:
    1,422
    Hey there,

    can I use the latest Version in a Production Environment?
     
  15. yuriythebest

    yuriythebest

    Joined:
    Nov 21, 2009
    Posts:
    1,121
    Greetings! I have a very old version of 2dToolkit and want to take advantage of the new features - is there a way to update without everything breaking?
     
  16. Code_Helix

    Code_Helix

    Joined:
    Feb 21, 2012
    Posts:
    79
    I'm still having issues using 2D Toolkit as my sprite continues to push right through my ground sprite which does have a collider and all I am using at the moment on my player sprite is a character controller and a rigidbody. Has anyone had this issue before as it doesn't make sense that the player will force itself through the collider of my ground sprite as it should've stopped it correct? I've also tried adding a rigidbody to the ground sprite but it does the same thing as well. If anyone has a working sample of a moveable player using this toolkit that be a great help as I can't figure out the problem.
     
  17. Code_Helix

    Code_Helix

    Joined:
    Feb 21, 2012
    Posts:
    79
    What do you mean by scale exactly? The size of what I have my sprite set to? If so all my sprites are scaled to 1x1x1 which I don't believe is a large scale but please correct if I'm wrong on that. Also with that scale the sprites become huge when using a regular camera and the scale in the editor doesn't change so I have to set the ortho FoV to 100 which is what I believe you said to set to 10 correct? Also wouldn't increasing the gravity cause the sprite the fall even faster?
     
  18. unikronsoftware

    unikronsoftware

    Joined:
    May 21, 2011
    Posts:
    1,287
    Don't see why not. There aren't any critical bugs as far as I'm aware, and it is in wide distribution right now.
     
  19. unikronsoftware

    unikronsoftware

    Joined:
    May 21, 2011
    Posts:
    1,287
    As far as I am aware, everything should be backwards compatible. Almost everything in there is versioned, either explicitly or implicitly. In theory, you should be able to import the latest version without everything going mental.

    If you're using javascript, make sure to restart Unity after updating, and then run "Setup for JavaScript" again.

    Always backup though - I don't test upgrades all the way back (usually just the last 3 updates).
     
  20. unikronsoftware

    unikronsoftware

    Joined:
    May 21, 2011
    Posts:
    1,287
    What I mean by scale is the physical size of sprites compared to Unity units.
    By default Unity assumes 1 unit = 1 meter. So something positioned at 0, 0, 0 and 1, 0, 0, means its 1 meter to the right.

    Sprites don't have any built in "scale" they are just scaled relative to the camera to display pixel perfect on the camera. That's why this is important for physics. Secondly, I don't know what your sprites describe - so the same sized sprites, representing 2 different things will require completely different scales, or the gravity settings changed to accomodate these. Eg. A 100x100 pixel sized ball representing a soccer ball, vs a 100x100 pixel sprite representing an asteroid.

    As mentioned just now, one of two things must change. Scale, or physics settings to accomodate what your units are representing.
    Scale is changed by changing the ortho size when using an ortho camera.

    The scale is fixed with the tk2dCamera, where 1 pixel = 1 meter. This is why you'll likely have to increase gravity, unless each pixel on your screen represents something 1 meter x 1 meter. You cant change the sprite size with the tk2dCamera, so you will have to change gravity, penetration, etc to compensate.

    With an ortho camera, the ortho size = number of units from top of screen to center of screen. So an ortho size of 10 => the top of the screen to bottom of the screen is 20 meters. You can actually work it out perfectly so you don't have to mess about changing any gravity or penetration settings anyhere. But this obviously depends on what your sprites represent. There isn't a magic number which will just work fine.

    Increase ortho size in the camera, and also the sprite collection. Make sure the sprite collection matches your camera, and your sprite will naturally be pixel perfect. You can tweak this by trial and error to find suitable numbers. If it drops too fast and penetrates the ground too much, it means your scale is too small. Increase your ortho size and try again. Once you find the suitable size for your game, you won't have to change it again.

    Hope that makes sense.
     
  21. Code_Helix

    Code_Helix

    Joined:
    Feb 21, 2012
    Posts:
    79
    I started over by using the tutorial that you have on using Unity Physics but the player object ends up endlessly bouncing up and down when using gravity. If I disable gravity and use Is Kinematic the player object will fall right through the ground when using my own coded gravity which is like every other gravity code I've come across as it works when using a tutorial for Orthello but don't like Orthello due to their lack of documentation on how to use it but with 2D toolkit I find the programming side far more difficult to get anything working. When using the Unity's physics for gravity I can get the bounce to stop if I use the rigidbody.AddForce() method but for some reason it will allow the player to jump more than the actual maximum allowed jumps. Wish someone who knows how to write tutorials will write a tutorial on making an actual game using 2D Toolkit to helps us noobs to figure out how to use it in Unity to control and move objects that use the toolkit.
     
  22. unikronsoftware

    unikronsoftware

    Joined:
    May 21, 2011
    Posts:
    1,287
    Have you looked at demo #4 and #8? Both do physics and objects fall at decent speed for the size. Maybe a touch floaty for my preferences, but otherwise a decent start. If you integrate your sprites into those scenes (i.e. get them to the right size in there) they should just work and behave like the rest of the sprites in there. Again as explained in my previous post, there aren't any magic numbers are going to fix everything for you. The numbers very much depend on how you set things up.

    Thing is about tutorials, no 2 peoples needs are going to be the same, especially with an open ended engine like Unity. We are working on one tutorial, but it isn't physics based but rather covers all the other basics, like putting a game together. Maybe after that we could do a physics based one, like an angry birds clone or something. Please post a request on our forum so it doesn't get lost in this thread: http://unikronsoftware.com/2dtoolkit/forum/index.php
     
  23. nemoryoliver

    nemoryoliver

    Joined:
    Nov 19, 2012
    Posts:
    38
    NEVERMIND: I really love your product. But I just want to know how can I make a tk2dButton on screen that will never move. Any suggestions please?

    I used the GuiCamera and learned from it. awesome plugin.
     
    Last edited: Apr 6, 2013
  24. Metabble

    Metabble

    Joined:
    Mar 29, 2013
    Posts:
    114
    I picked up a copy of 2D Toolkit of the other day, and it's very useful. However, making a prototype platform game with it as a learning exercise has brought up some questions regarding rigidbody physics that I hope you can answer.

    1. I noticed that after moving to using the tk2dcamera, I've had to increase the collider depth of objects quite a bit from the standard. When I first starting using it, my rigidbody + box collider hero would fall through other box colliders when he landed on them. After increasing the collider depth so that the collider depth was half the width–20 or so–the problem went away. When I implemented a ground pound mechanic with an impulse force of about 300, however, he started going through the floors occasionally again. The only thing that seemed to help was increasing the collider depth. Making all of my sprites have colliders that are almost perfect cubes seems to have resolved most of my problems, but I'm curious as to why this is necessary.

    2. Using rigidbody physics for my character movement makes him sometimes end up unaligned and blurry. For example, he might have an x position of 0.43, or some other wacky number. Is there any better way to ensure that sprites stay aligned, other than rounding their position to the nearest integer when you want them to appear crystal clear?

    3. Finally, how do you prefer to keep a UI element (such as a text mesh) aligned with the camera, as part of a static HUD? Right now, I just child the UI element's transform to the tk2dcamera's so that it moves with the camera, and it works fine. Is this the best approach?

    Thank you for your time. :)
     
    Last edited: Apr 8, 2013
  25. unikronsoftware

    unikronsoftware

    Joined:
    May 21, 2011
    Posts:
    1,287
    1. Not sure about the precise issue you're experiencing, but 2D Toolkit just uses Physx. I recommend searching through answers.unity3d.com - any general physx stuff applies directly here.

    2. Turn off mipmaps. Quick, easy, and produces decent enough results.

    3. Create a second camera, keep it static and position everything the way you'd like in there. Check sample #6 - this uses 2 cameras. The other option is to make the hud elements children of the camera in the hierarchy, but if you're moving the camera loads, this can result in the sprites occasionally moving ever so slightly.
     
  26. Metabble

    Metabble

    Joined:
    Mar 29, 2013
    Posts:
    114
    1. Alright. I couldn't really find a conclusive answer, but it doesn't matter. As long as it works!
    2. Started it up today and the problem is gone. I must've already fixed it sometime earlier. Sorry about that.
    3. Another camera, of course! I'll give that a try.

    Thank you for your time. Keep up the good work, 2D Toolkit is great. :)
     
  27. JustDave1961

    JustDave1961

    Joined:
    Jan 5, 2013
    Posts:
    14
    Posted: 10:31 PM 2 Hours Ago

    Hi,
    I purchased 2d toolkit for a 2D Android game I'm about to begin because it seems to be the only 2d camera solution that handles different device resolutions the way I would like.

    I have a question though. I started a new project, deleted the main camera, created a tk2dCamera, created a Cube and placed it a 0,0,0.
    The thing is, I can't see the cube! This confuses me because it should be there! I can move it and/or change it's scale but I still can't see the cube. (It doesn't show up in any of the preview windows (tk2dCamera, Camera Preview or Game).
    If I set the tk2dCamera Size to 1, the cube shows up in the "Camera Preview" window but no where else.
    If I then create a 'normal' Unity Camera, I can immediately see the cube in that camera's preview window and the game window. I even tried a 2D plane with a texture on it and scaled it way up and still can't see anything. Is this normal behavior for 2d Toolkit? It just seems odd to me that I can't see the cube at all with the tk2dCamera.
    Any feedback on this would be most appreciated.
    Thank you.

    I'm using:
    Unity 4.1.2f1
    Windows 8
    8GB RAM
    1 TB Hard Drive
     
  28. unikronsoftware

    unikronsoftware

    Joined:
    May 21, 2011
    Posts:
    1,287
    1 world unit in the tk2dCamera, without overrides, is 1 pixel. The default cube in Unity is 1x1x1 units, so it will be one pixel in size. Scale it up by 100x100 and now it should be visible, and it will be 100x100 pixels in size.

    The origin with the tk2dCamera is at the bottom left. That means that the cube, by default will be at the bottom left of the game window / tk2dCamera preview.

    Note:
    Unfortunately, the "Camera preview" window is buggy, which is why its showing you incorrect data in there. Thats also the reason theres a custom tk2dCamera preview to the left. This bug was reported close to a year ago and it still hasn't been fixed :( If you collapse the Camera component on the tk2dCamera, the camera preview will disappear and not be as confusing.
     
  29. JustDave1961

    JustDave1961

    Joined:
    Jan 5, 2013
    Posts:
    14
    Thanks for the quick reply.
    I had already found all the things that you had said online before I posted.
    The Cube just didn't show up no matter where I put it or how I scaled it.
    I uninstalled then re-installed Unity, reloaded the same project there was the cube.
    I guess there was something weird going on with Unity.
    This will probably be a good thing to remember in case anyone else has a strange problem like mine.

    Thank you!
    Dave
     
  30. Blobfish

    Blobfish

    Joined:
    Feb 28, 2013
    Posts:
    30
    Hello,

    Would it be possible to do something like the game worms (destructible terrain) with this toolkit?
     
  31. Haptix Games

    Haptix Games

    Joined:
    Aug 8, 2012
    Posts:
    29
    No Blobfish, destructible terrain is a whole can of worms that you do not want to open. Our game, H2FLOW , has it... and water physics... we essentially have a plane with our level, then when a bomb explodes in that area we write transparency to the image.

    You would'nt want to keep this image in an atlas because you'd be rewriting that atlas every time there is a change (explosion). We use getpixels and setpixels to get pixel accurate.

    If I were you, I would recommend using small tiles like where's my water does. Each tile has a possibility of being 1 of 10 hole variations.. or combos if it is next to an already exisiting hole.
     
  32. Blobfish

    Blobfish

    Joined:
    Feb 28, 2013
    Posts:
    30
    Okay, thank you very much :)
     
  33. SpaharGR

    SpaharGR

    Joined:
    Dec 5, 2012
    Posts:
    11
    Hello, I am trying to make a 2D platform and I need it to be extremely dark in some levels with only a few light sources. I searched in the forums and although I found similiar questions to mine, noone had given any good or any answer at all.

    To explain it better, I want the player to be able to see only a small part of the level around the character (lantern effect) and maybe some other parts due to other light sources (for example candles). How is this possible with 2D Toolkit? Do I need a custom shader (I haven't programmed any before)?

    Thanks.
     
    Last edited: Apr 10, 2013
  34. unikronsoftware

    unikronsoftware

    Joined:
    May 21, 2011
    Posts:
    1,287
    For starters, I'd just switch the sprite collection to a lit shader and use Unity lights. As long as you don't have too many lights, the performance should be pretty decent. I'd get going with this first and then optimize later - there are many possible optimization avenues available.

    You might have to add a bit of code to generate normals in the tilemap (it doesn't by default). Drop me an email at support at unikronsoftware dot com and I'll tell you what needs to be added and where.
     
  35. SpaharGR

    SpaharGR

    Joined:
    Dec 5, 2012
    Posts:
    11
    I sent you an email. Thanks a lot!
     
  36. J_P_

    J_P_

    Joined:
    Jan 9, 2010
    Posts:
    1,027
    I have 2D background elements that I'd like to have repeat horizontally. Is there a good way to do that? They don't need colliders, so I can't use vertex snapping to tile them. Is there another way or do I just add colliders anyway?

    I think in a perfect world, I'd just be able to stretch it for how long I need it and have it automatically repeat the texture as necessary. Haven't found that functionality though.
     
    Last edited: Apr 11, 2013
  37. Silly_Rollo

    Silly_Rollo

    Joined:
    Dec 21, 2012
    Posts:
    501
    Could you maybe add the normal map instructions to your doc or a faq post? I'd be curious about it as well.
     
  38. unikronsoftware

    unikronsoftware

    Joined:
    May 21, 2011
    Posts:
    1,287
    1. You can use vertex snap without colliders. Just hover over a vertex press V and drag to the vertex you want to snap to.

    2. In tk2d 1.92, you can create a tiled sprite. Just set the dimensions you want and tk2d will tile the texture for you :)
     
  39. J_P_

    J_P_

    Joined:
    Jan 9, 2010
    Posts:
    1,027
    Weird.. vertex snapping wasn't working before. Works now. Will also try tiled. Thanks!
     
  40. unikronsoftware

    unikronsoftware

    Joined:
    May 21, 2011
    Posts:
    1,287
    There is a thread in our private support forum illustrating the required steps to do this, and some other discussion threads about this too.
    http://unikronsoftware.com/2dtoolkit/forum/index.php/topic,947.msg6836.html#msg6836
    http://unikronsoftware.com/2dtoolkit/forum/index.php/topic,1289.msg6162.html#msg6162
    http://unikronsoftware.com/2dtoolkit/forum/index.php/topic,1143.0.html

    A future version will have built in support to automate the entire process - in the mean time while its possible to do so, it does require some manual set-up.
     
  41. kremedved

    kremedved

    Joined:
    Nov 8, 2012
    Posts:
    14
    Hi! How can I scale the size of the sprites in atlas without replacing with new images sprites?
    For example: 1280x800 - 1:1, 800x480 - 1:2, 480x320 - 1:3
     
  42. unikronsoftware

    unikronsoftware

    Joined:
    May 21, 2011
    Posts:
    1,287
    Instead of changing sprite sizes, why not just change the camera parameters? That way you can even use the same positioning from before, and everything will just work.
     
  43. mohammad han

    mohammad han

    Joined:
    Apr 14, 2013
    Posts:
    1
    hello unikronsoftware
    we are creating 2d game using unity engine it isometric city building game , i have plane with 2d texture (land image) also the camera type is orthographic and its fixed at specific position (Top View Camera) , we place the images (houses) on the land at fixed y position we arrange them using render queue in code, the images are overlapped as expected, we have 2 problems the first problem in the touch area where there is intersection between the images when the player touch's an image it select the wrong image (the image in the back not in the front). the second problem is the selection in transparent area of the image, currently we are using box collider and we dont want the player to select the image in transparent areas.

    here is screenshot to clarify my scene view

    $Capture.PNG

    is the 2d toolkit have something to handle these issues? plz say yes :) if not what we can do to fix it.
    thanks in advance
     
  44. Issam Shadid

    Issam Shadid

    Joined:
    Feb 24, 2013
    Posts:
    1
    hi

    i have the same situation like "mohammad han"
    plz replay to us
     
  45. unikronsoftware

    unikronsoftware

    Joined:
    May 21, 2011
    Posts:
    1,287
    Ok before I answer the question I need a bit more information about what you're doing and why.
    1. If you're using a top view, I guess you've just rotated your sprites?
    2. The house sprite - any reason you're using a normal plane and not a sprite?
    3. Why are the y values all the same? If you arrange them in y by the order you want them to draw in you wont have to use render queues at all. Also, if you did this, then raycast picking will work precictably and accurately.
    4. Use the polygon collider tool in tk2d to draw the outline for your house and you should be able to pick it precisely. Be sure to build front and back collider caps to be able to pick them.
     
  46. Acegikmo

    Acegikmo

    Joined:
    Jun 23, 2011
    Posts:
    1,294
    Hello! I've got an odd issue:

    Code (csharp):
    1. public tk2dSprite sprite;
    2.  
    3. void Start () {
    4.     Debug.Log(sprite.Collection);
    5.     Debug.Log(sprite.Collection.Count);
    6.     Debug.Log(sprite.Collection.spriteDefinitions.Length);
    7. }

    When that is run, it prints:

    Code (csharp):
    1. sc_gui_main (tk2dSpriteCollectionData)
    2. 75
    3. 0

    Why is the spriteDefinitions array empty?
     
  47. kremedved

    kremedved

    Joined:
    Nov 8, 2012
    Posts:
    14
    I need a different size of atlases for different screen resolutions. No sense to store graphics 1280x800 for devices with 480x320, besides the size of the application so becomes less
     
  48. unikronsoftware

    unikronsoftware

    Joined:
    May 21, 2011
    Posts:
    1,287
    I see what you mean. You can't do that yet. If you want to implement it yourself I can make some recommendations. If your use case is limited it shouldn't be too complicated at all. Drop me an email to support and I'll describe what you need to do.
     
  49. unikronsoftware

    unikronsoftware

    Joined:
    May 21, 2011
    Posts:
    1,287
    Are you using platform sprite collections? If so, this is a bug. Try this instead: sprite.Collection.inst.spriteDefinitions.Length;
     
  50. JustDave1961

    JustDave1961

    Joined:
    Jan 5, 2013
    Posts:
    14
    Hi,
    I've started playing around with TexturePacker support in 2D Toolkit and I found something odd.
    I'm using the tk2dCamera with these override settings:
    $Camera.png

    I am using the code in the tk2dDemoRuntimeSpriteController.cs file as a reference and have 8 32X32 tiles that I am piecing together at runtime (by creating a SpriteCollection Sprites).

    With the above camera settings I get this result:
    $Bad.png

    There is some strange drawing issues going on. I found the issue to be caused by the Auto Scale setting of the tk2dCamera because when I set it to Pixel Perfect Fit, I get this (which is correct):
    $Good.png

    All the other Auto Scale modes cause the same issue.
    Any help with this would be greatly appreciated.