Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice
  3. Dismiss Notice

SM2 - 2D made easy and efficient!

Discussion in 'iOS and tvOS' started by Brady, Nov 4, 2009.

  1. Dreamora

    Dreamora

    Joined:
    Apr 5, 2008
    Posts:
    26,601
    mail brady ... seems like its not only the eDS ones that are crippled by esselerates crap system but also others then ...

    really asking myself why they start a service if they are significantly worse than shareit in their offer ...
     
  2. Maph

    Maph

    Joined:
    Sep 19, 2009
    Posts:
    55
    I'll do just that, cheers!

    I take it you've had some bad experiences with esellerate in the past? :)
     
  3. helmishariff

    helmishariff

    Joined:
    Nov 29, 2007
    Posts:
    107
    me too.
     
  4. Dreamora

    Dreamora

    Joined:
    Apr 5, 2008
    Posts:
    26,601
    Kind of.
    I guess I was the one who first got hit by the eDS unlogic and required to get any of the RC past RC1 beeing sent through mail ...
     
  5. Brady

    Brady

    Joined:
    Sep 25, 2008
    Posts:
    2,474
    Sorry about that, guys! It looks like eSellerate has yet another obstacle to providing updates to my customers. :( So I'm in the process of figuring out another system. Until then, I've e-mailed each of you directly with the latest version. I'm sure some of you have already been able to download RC5 and are getting this message redundantly, so I apologize, but I want to make sure everyone gets it and doesn't have to ask for it first.

    Thanks!
     
  6. wesrm

    wesrm

    Joined:
    May 20, 2009
    Posts:
    193
    Wow! This tool is absolutely incredible. Thanks for creating SM2. Great Work! Hoping for UI tools in SM3 : )
     
  7. Gaspedal

    Gaspedal

    Joined:
    Mar 29, 2009
    Posts:
    376
    Brady, can you post a example from Demo.cs as Java Version ?
    I have tried to convert it to java but it doesn't work. I want call your control functions from javascript. Is this possible ?
     
  8. Brady

    Brady

    Joined:
    Sep 25, 2008
    Posts:
    2,474
    Sure, I'm not much of a JS scrpiter, but I can probably put something together for you. Give me a couple of days, if it's no problem for you, as I have done other projects that need attention. Otherwise, let me know if it is urgent.
     
  9. Gaspedal

    Gaspedal

    Joined:
    Mar 29, 2009
    Posts:
    376
    Thanks, that would be great. There's no hurry.
    it would be enough for me when I know how to declare the first lines in Java.

    public PackedSprite funkySprite;
    ...

    and calling the function with sprite handle

    funkySprite.PlayAnimInReverse("Look up");
    ...
    ....

    My Game is 60% written in C# but a lot of scripts are written in Java.
     
  10. minevr

    minevr

    Joined:
    Mar 4, 2008
    Posts:
    1,018
    Why am I unable to access your site, I would like to see video :eek:
     
  11. Brady

    Brady

    Joined:
    Sep 25, 2008
    Posts:
    2,474
    I'm not sure, it seems to be working for me. Perhaps my webhost had some downtime over the night (my time)? Please try it again and let me know if it is still not accessible to you.
     
  12. rocket5tim

    rocket5tim

    Joined:
    May 19, 2009
    Posts:
    242
    I'm getting the following error when I build sprite atlases (I'm using RC5):

    My textures are 512x512 png's and there are currently 2 assigned to the material (just as a test). I assumed that I could have up to 4 512 textures on a single 1024 atlas, but for some reason it keeps resizing them down to 256.

    How can I create a 1024 atlas with 4 512 textures without it resizing them to 256?
     
  13. Brady

    Brady

    Joined:
    Sep 25, 2008
    Posts:
    2,474
    This is probably occurring because you have padding. So if you have 512x512 pngs but are using 1 pixel of padding between them, then it's going to result in a one-pixel overage. Try setting the padding to 0 and that should do it.

    The default value for padding in the atlas builder is 1 pixel. This helps to fight "bleeding" from neighboring images. But this is not always needed.
     
  14. tonyd

    tonyd

    Joined:
    Jun 2, 2009
    Posts:
    1,224
    I would appreciate this as well...
     
  15. rocket5tim

    rocket5tim

    Joined:
    May 19, 2009
    Posts:
    242
    D'oh! Yep, setting the padding to 0 fixed it. Thanks!
     
  16. rocket5tim

    rocket5tim

    Joined:
    May 19, 2009
    Posts:
    242
    Is there any way to check if a specific animation is currently playing on a spirte (using PackedSprite)? And if it is, wait until it's finished before doing something else?

    In my animation controller, I want to make sure the "land" animation finishes before going back to the "idle" animation.

    If this was a traditional animation, I'd use AnimationState.normaizedTime to check where in time we are in the current animation. Is there anything like that in SM2?

    Update: I just noticed SetAnimCompleteDelegate, but I can't quite figure out how to use it in a javascript. I'm also not sure what your definition of a "delegate" is.

    I also noticed GetLength(), GetDuration(), and GetFrameCount() in the UVAnimation class, but they apparently aren't part of PackedSprite. Seems like they'd be pretty handy for sprite anims, eh?
     
  17. Lokken

    Lokken

    Joined:
    Apr 23, 2009
    Posts:
    436
    This is somewhat related to this thread.

    Do any of you have resources as far as sprite animation creation?

    Tools, tutorials, etc?
     
  18. championsoftware

    championsoftware

    Joined:
    Jan 8, 2009
    Posts:
    123
    Hey Brady I talked to you briefly at Unite, great job on the new Spritemanager.

    I currently have the old Spritemanager implemented with code in the following way. I am using my sprites in 3d space and recycle them when more aren't needed.

    Code (csharp):
    1.     if(!singleton.LinkedSpriteManager)
    2.                     return;
    3.                 Vector2 tvt = new Vector2(increment,0f);
    4.                 Vector2 tvNew = new Vector2(increment, 1f);
    5.                 Transform empty = (Transform)Instantiate(spawnPoint);
    6.                 empty.position = spawnPoint.position;
    7.                 empty.rotation = spawnPoint.rotation;
    8.                 //Debug.Log("CreatingSprites");                
    9.                 Sprite tempSprite = singleton.LinkedSpriteManager.AddSprite(empty.gameObject,2f,2f,tvt,tvNew,false);
    10.                 tempSprite.hidden = false;
    11.    
    12.                 allEnemiesSprites.Add(tempSprite);
    The only problem I am having is that the z-order of my sprites will not adjust automatically. One enemy will be behind another but draw on top of him. From the looks of it(from manual tests) the new SpriteManager solves this problem. So my question is how do I programatically generate sprites with the new SpriteManager or just simply tweak the old LinkedSpriteManager to automatically correct the Z-order?

    Here are some pictures to show what I'm talking about.

    Thanks for any help.



     
  19. Gaspedal

    Gaspedal

    Joined:
    Mar 29, 2009
    Posts:
    376
    @Brady: I have now converted my game 100% to C# Scripts. I don't need more example for the usage in Java. :D
     
  20. Brady

    Brady

    Joined:
    Sep 25, 2008
    Posts:
    2,474
    meanstreak:
    It looks like you found most of the methods that pertain to what you're wanting to do. Another one would be PackedSprite.GetCurAnim() which returns the current animation (null if none is being used), as well as IsAnimating(), which returns whether the sprite is animating. As for GetLength(), GetDuration(), etc, these are not part of PackedSprite because they are sprite animation methods - not sprite methods. In other words, to use them, you would do: mySprite.GetCurAnim().GetLength(). Or something along those lines. In other words, PackedSprite has a "Has A" relationship to an animation, not an "Is A". So these methods are called on the animation objects themselves, not the sprite object. I hope that makes sense. If not, let me know and I can help out further.

    As for using a delegate with JS, I believe all you need to do is declare a function that fits the profile of the delegate prototype. So in this case, that would be a function that accepts no arguments and returns no value. Then just pass SetAnimCompleteDelegate() the name of the function and it should work. I'm still working on getting a JS version of the demo script out so that should clarify a lot of this.

    Lokken:
    Well, SM2 is a pretty good tool for creating sprite animations if I do say so myself. :) But I think you probably mean creating the artwork itself? If so, there are lots of possible answers to that question, but I'd say if you're wanting to animate characters, one quick, cheap, and easy way to go is Daz 3D. It's free, and then the models for it are cheap and fully-rigged, so you can pose them/animate them, and render each frame to a bitmap to be used in a sprite animation sequence.

    championsoftware:
    In the old SM, the solution would be to use drawLayers (which would be somewhat of a poor fit in your game, it would seem, though somewhat workable). But in SM2, Unity handles the Z-sorting, so the effect shown in your screenshot should not occur with SM2 as long as the sprites are positioned where you want them depth-wise with respect to the camera. In other words, there's nothing special that has to be done to get them not to draw ontop of eachother incorrectly.

    Gaspedal:
    I'm glad for you, C#, in my opinion and also in the opinions expressed by many of the presenters at Unite, is the way to go. :) But I'm still going to do up a JS version for those who still need it as I'm sure there are many. But congratulations on going all C#! :)
     
  21. minevr

    minevr

    Joined:
    Mar 4, 2008
    Posts:
    1,018
    In China,not access it.so bad.

    Make a mirror URL?Thanks
     
  22. Gaspedal

    Gaspedal

    Joined:
    Mar 29, 2009
    Posts:
    376
    China has blocked a lot of video portals and server IP's. Maybe he can upload the files on rapidshare or so.
     
  23. Lokken

    Lokken

    Joined:
    Apr 23, 2009
    Posts:
    436
    Thanks!

    Don't worry. I fully intend to take advantage of SM2 :)
     
  24. minevr

    minevr

    Joined:
    Mar 4, 2008
    Posts:
    1,018
    Yes, this way, developers are very depressed thing.
    Want to upload to rapidshare.
    I also hope to see more screenshots. My poor network :(
     
  25. Brady

    Brady

    Joined:
    Sep 25, 2008
    Posts:
    2,474
    Minevr, are the some particular files you would like to view, such as the tutorial videos? If there's anything specific I can do to help, let me know.
     
  26. minevr

    minevr

    Joined:
    Mar 4, 2008
    Posts:
    1,018

    This tool uses, screenshots, tutorials, videos, etc., I would like to know about it.

    Thank you. :roll:
     
  27. Brady

    Brady

    Joined:
    Sep 25, 2008
    Posts:
    2,474
    Okay, I'll see what I can do. :)
     
  28. zcity

    zcity

    Joined:
    Nov 15, 2009
    Posts:
    7
    do you have a demo / trial of your plugin ?
    I'd like to try if it's applicable to my next project before i invest some money on it 8)
     
  29. Dreamora

    Dreamora

    Joined:
    Apr 5, 2008
    Posts:
    26,601
    SM2 is source based, not a dll (-> hard to impossible for trials).

    The videos on the website show you the things that are to know about it and its features :)
     
  30. zcity

    zcity

    Joined:
    Nov 15, 2009
    Posts:
    7
    Ok then, thank you.
     
  31. Brady

    Brady

    Joined:
    Sep 25, 2008
    Posts:
    2,474
    dreamora is correct. But if after viewing the videos you still have questions, please feel free to ask any questions you may have about it.
     
  32. steddyman

    steddyman

    Joined:
    Apr 10, 2009
    Posts:
    253
    Hi Brady

    I am using RC5 and think there may be a bug in how you calculate the Pixel Perfect size for sprites.

    In my game I am using SM2 for two functions:

    1. Game sprites using an Orthographic camera with a size of 110
    2. UI sprites on a UILayer using an Orthographic camera with a size of 160

    Game sprites with the Auto Size / Pixel Perfect setting display correctly.

    UI sprites with the Auto Size / Pixel Perfect setting show around 2/3rd the size they should be.

    If I set the camera size of both the Main and UI Cameras to the same value, then the size of the UI sprites scale correctly.

    So it looks like the UI sprites are calculating the size based on the Main Camera, rather than the UI camera that is actually rendering them.
     
  33. Brady

    Brady

    Joined:
    Sep 25, 2008
    Posts:
    2,474
    steddyman, this is correct, by default, pixel-perfect sprites use the main camera. To use a different camera for a particular sprite, you must tell it which camera to use by calling SetCamera() and pass it a reference to the desired camera. You can find documentation on SetCamera() in the SM2 scripting reference.
     
  34. steddyman

    steddyman

    Joined:
    Apr 10, 2009
    Posts:
    253
    Hi Brady

    Thanks for clarifying that and responding so quickly.

    I hadn't spotted that.
     
  35. Brady

    Brady

    Joined:
    Sep 25, 2008
    Posts:
    2,474
    No problem, steddyman. :)

    Okay, I have attached the JS version of the demo script here. All future releases will include this with the package, but for now, anyone needing samples of how to do things with SM2 using JavaScript can download it here.

    Some of the things demonstrated here are how to use animation complete delegates, handle resizing colliders when a sprite is resized (using a delegate), playing, changing, pausing animation, etc.

    Also be aware that if you are going to call SM2 from JavaScript, you need to put the "Sprite Scripts" folder under a folder called "Plugins" off of the root, or some other folder that gets compiled first (see the Unity docs regarding compile order for other possible folder names). This is so that the C# classes get compiled before your JS to ensure that your JS recognizes the class names.

    Have fun!
     

    Attached Files:

  36. steddyman

    steddyman

    Joined:
    Apr 10, 2009
    Posts:
    253
    Hi Brady

    Is there any chance you could add the Camera as an optional variable on the Sprite and PackedSprite components? If it is defined then use it and if it isn't then use the Main Camera.

    I wrote a simple script to set the camera on a Sprite object and it worked, however the preview of the sprite in the GUI still shows completely wrong because until the App is running then the GUI still thinks it is the Main Camera.

    For use as a GUI, this sucks since you can't then lay out the GUI sprites.

    Thanks
     
  37. Brady

    Brady

    Joined:
    Sep 25, 2008
    Posts:
    2,474
    I see what you mean. That is a good idea. So something like a public property that you could just drag a reference to would work for what you're wanting? I'll add this to my todo list for the next version. In the meantime, try this: Find where "curCamera" is declared in SpriteBase.cs, and change it from "protected" to "public". This should make it appear in the inspector. Then in both Start() and Init(), put the following line before "SetCamera()" (so as to make the SetCamera() call conditional on the following 'if' statement):

    Code (csharp):
    1. if(curCamera == null)
    I have not tested this yet, but I expect that should do it.
     
  38. greensquidsolutions

    greensquidsolutions

    Joined:
    Nov 2, 2009
    Posts:
    47
    Hi,

    I was wondering if you could make a tutorial video on making a simple 2d game with SM2. When I downloaded unity I found a cool tutorial on making a simple space invaders game which helped me like unity, if there was something similar for your product I could work out if yours could help me.

    The videos you have on how to it makes your life better is great, but for someone who hasn't used and wants to use 2d gaming makes your product look great, but would like to see something concrete first.

    Sorry for being a pain :)
     
  39. Brady

    Brady

    Joined:
    Sep 25, 2008
    Posts:
    2,474
    Thanks for the suggestions. That's a good idea! I'll add that to my list of possible future additions.
     
  40. Bububear

    Bububear

    Joined:
    Mar 1, 2009
    Posts:
    106
    Hi Brady,

    Just out of curiosity, are there any plans for SM2 to incorporate some kind of "tilemap generation" feature? I think this would be a great addition considering the current 2D capabilities of SM2.

    What do you think? :D
     
  41. steddyman

    steddyman

    Joined:
    Apr 10, 2009
    Posts:
    253
    Hi Brady

    I get the following error when launching the Editor inside Unity iPhone Adanced 1.5.1 RC1:

    Unable to find required resource at 'Editor Default Resources/Builtin Skins/Lucida Grande Small.ttf'
    UnityEditor.EditorWindow:Show(Boolean) (at /Users/build/builds/unity-iphone-1.5/iphone-1.1/Editor/Mono/Generated/Utility.cs:671)
    SpriteTimelineEditor:ShowWindow() (at Assets/Editor/SpriteTimelineEditor.cs:109)

    It does look like it works, though seems a little untidy with fonts extending outside the controls.

    Thanks
     
  42. Brady

    Brady

    Joined:
    Sep 25, 2008
    Posts:
    2,474
    Bububear:
    I'm certainly considering it. Or alternatively, to have it work with existing tile editors out there. It would certainly be a cool feature. :)

    steddyman:
    Yes, I've received a couple reports of this now, and have seen this on my end as well, but I'm not sure anything can be done about it (and as you pointed out, it does not impact functionality), as I believe it has something to do with the diminished editor GUI support in Unity iPhone, which will hopefully be fixed in the next release or so. I've searched around for info on this error and I have not yet been able to figure out what causes it. It is trying to use a built-in font (SM2 doesn't use any special skins or fonts, just whatever the Unity default is), so I have no idea why Unity isn't finding its own default font. I did try addressing this by using a custom font and custom skin, but that didn't affect it.

    If anyone has any insight into this, I'd be interested in hearing about it.
     
  43. Bububear

    Bububear

    Joined:
    Mar 1, 2009
    Posts:
    106
    Would be cool indeed! Glad to hear that it's already under consideration.

    With tilemap integration, I can definitely see SM2 being set apart from just a "sprite/atlas generator", and transition more into more of a "2D platform engine" type of product. At least that's how I see it. :)
     
  44. steddyman

    steddyman

    Joined:
    Apr 10, 2009
    Posts:
    253
    Hi Brady

    That sounds like a bug in Unity iPhone 1.5. It may be worth you logging it as such with the bugtracker in order to get a definitive response.
     
  45. Brady

    Brady

    Joined:
    Sep 25, 2008
    Posts:
    2,474
    I could have sworn I had (I've reported a lot lately), but I couldn't find a confirmation for it, so I just submitted one for this. Thanks for reminding me!
     
  46. mudloop

    mudloop

    Joined:
    May 3, 2009
    Posts:
    1,107
    If you ever implement tile support, I recommend the editor Tiled (www.mapeditor.org), IMHO the best tile map editor I've worked with.

    It would be nice if you could set up parallax speeds for different layers too...

    Currently I have no need for SM2, but with these features, I'd buy it instantly.
     
  47. Brady

    Brady

    Joined:
    Sep 25, 2008
    Posts:
    2,474
    Yes, I'd received a few other recommendations of that one, and that's the one I'm currently looking at. I'm glad to have another vote for that one. :)
     
  48. mudloop

    mudloop

    Joined:
    May 3, 2009
    Posts:
    1,107
    A while ago I created an ActionScript3 library to import Tiled maps. If it can help you, I can see if I can still find it.
     
  49. Brady

    Brady

    Joined:
    Sep 25, 2008
    Posts:
    2,474
    Sure, sounds great. You can e-mail me directly via the addy on my website, or PM me.
     
  50. helmishariff

    helmishariff

    Joined:
    Nov 29, 2007
    Posts:
    107
    How to stop animation looping? In standard animation, we can use animation.Stop().

    I would like my animation only play once. No looping. How to set it? Thanks.