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

[RELEASED] 2D ColliderGen - Generate Precise Polygon Colliders For Your 2D Sprites

Discussion in 'Assets and Asset Store' started by Pixelcloud-Games, Mar 14, 2013.

  1. Pixelcloud-Games

    Pixelcloud-Games

    Joined:
    Apr 29, 2011
    Posts:
    160
    2D ColliderGen is now available on the Asset Store for 30$

    [HR][/HR]Create Precise Polygon Colliders for Entire Scenes at the Click of a Button - Instant 2D Physics

    The 2D ColliderGen framework allows you to automatically generate precise polygon colliders for your game objects from a sprite image’s alpha-channel. The colliders are created within the Unity3D editor in order to have no performance impact at runtime.

    Automatically integrates with:
    SmoothMoves, 2D Toolkit and Orthello (Free, Elements and Pro) - Scroll down for tutorial videos.
    Can be used with other 2D packages or completely without one, too - see this page for more info.

    Visit the Official Webpage with FAQ Section
    Visit the Documentation Pages
    Buy now on the Unity Asset Store

    Features:
    • Simple parameters, optimal results – vertex count, alpha threshold and more.
    • Adds no additional performance cost at runtime – colliders are created entirely within the editor.
    • Multi-object editing support.
    • Colliders can be forced convex for movable objects.
    • Even works with SmoothMoves BoneAnimation characters.
    • Works with Unity 3.x and 4.x.
    • Supports all versions of Unity – no requirement for Unity Pro.

    $2dcollidergen_main_slide.jpg

    $screen1_polygon_colliders.jpg

    $screen2_parameters_mirrored.jpg

    $screen3_multi_object_editing.jpg

    $screen4_integrates_with.jpg

    [HR][/HR]
    Tutorial Videos for each Framework

    2D Toolkit


    SmoothMoves (Note the support for BoneAnimation characters)


    Orthello


    Hope you like it!
    If you have any questions, don't hesitate to ask!

    Kind regards,
    Harald
     
  2. Pixelcloud-Games

    Pixelcloud-Games

    Joined:
    Apr 29, 2011
    Posts:
    160
    One more image - could not upload it in the last post.
    $screen5_animated_smoothmoves.jpg
     
  3. mas

    mas

    Joined:
    Nov 14, 2010
    Posts:
    696
    Nice extension and thanks for supporting Orthello with it!
    Keep up the good work.

    P.s. Had auto generated mesh planned for the long run but you gave me
    some spare time ;) Thanks.
     
  4. unikronsoftware

    unikronsoftware

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

    echo17

    Joined:
    Nov 24, 2011
    Posts:
    1,249
    Very cool! Can't wait to see what people can do with this useful extension!
     
  6. meta87

    meta87

    Joined:
    Dec 31, 2012
    Posts:
    254
    Awesome, support for my two fav frameworks (smoothmoves 2dtk)! This looks great, will be picking up soon.
     
  7. Pixelcloud-Games

    Pixelcloud-Games

    Joined:
    Apr 29, 2011
    Posts:
    160
    Thanks everyone for your kind feedback! :)
     
  8. Pixelcloud-Games

    Pixelcloud-Games

    Joined:
    Apr 29, 2011
    Posts:
    160
    @mas
    Thank you! Of course, Orthello is a great framework - it just can't be left out!
    Great, always glad to help ;)

    @unikronsoftware
    Thank you, glad you like it!
    Thank you very much, that would help us a lot!

    @echo17
    Thank you! We're very excited too! I'm going to post that people can post their screenshots here if they want, I would love to see what they come up with!

    @meta87
    Thank you! Hope you like it! If you do, we would be very happy about a positive asset store review, since we have don't have any ratings yet.. ;).
     
  9. Pixelcloud-Games

    Pixelcloud-Games

    Joined:
    Apr 29, 2011
    Posts:
    160
    Everyone who uses 2D ColliderGen:
    Feel free to post images and screenshots of your games here!
    We are so excited to see what you use our extension for!
    Thank you! :)
     
  10. Pixelcloud-Games

    Pixelcloud-Games

    Joined:
    Apr 29, 2011
    Posts:
    160
    And of couse, if you have any questions, feel free to post them here!
     
  11. p6r

    p6r

    Joined:
    Nov 6, 2010
    Posts:
    1,158
    PM sent...
    6R
     
  12. PsychoG

    PsychoG

    Joined:
    Jan 11, 2013
    Posts:
    42
    Awesome! It saves so much time! I'm a little new to how mesh colliders work because Ive been using box colliders throughout my whole unity experience but they guys made it easy. Seriously just one button and boom perfect colliders.
    Thank you so much! Will post videos of a level made with 2dColliderGen. !
     
  13. Pixelcloud-Games

    Pixelcloud-Games

    Joined:
    Apr 29, 2011
    Posts:
    160
    Thanks very much! Looking forward to your level shots!

     
  14. Ocid

    Ocid

    Joined:
    Feb 9, 2011
    Posts:
    476
    Hey Pixelcloud.

    Not sure if I'm reading this wrong but I thought I'd ask.

    Does this support collider gen at runtime? Sure I'll pick it up eventually but thought I'd ask first.
     
  15. MonsterGamingHD

    MonsterGamingHD

    Joined:
    Feb 15, 2013
    Posts:
    39
    Or you can just create a mesh collider.
     
  16. Pixelcloud-Games

    Pixelcloud-Games

    Joined:
    Apr 29, 2011
    Posts:
    160
    Hi Ocid, thanks for your interest in our extension!

    Basically yes - you could use 2D ColliderGen for runtime-purposes, but (for now) not as comfortable as using it in offline pre-processing mode, depending on what you want to acomplish.

    What exactly would you like to do at runtime? If the MeshColliders could be calculated in offline-mode in the editor, and you only need to enable and disable some collider-GameObjects at runtime, it would be rather easy (tried and tested this myself).

    If you really need to adapt to dynamic changes at runtime and offline pre-processing is not an option, then you could still utilise 2D ColliderGen functionality, but with a bit more coding involved: The plugin provides methods such as BinaryAlphaThresholdImageFromTexture(), TriangleFenceOutlineFromBinaryImage(), etc, that could be used for this purpose. Note however that these calculations take some time, so it depends on your requirements.

    However, we have not yet tried modifying MeshColliders at runtime, but you could have a look at these forum posts here [1] [2]. The Unity engine itself could come with some performance-limitations in this case, so we suggest that you try out changing MeshColliders at runtime first to see if this fits your performance requirements.

    If it does, feel free to ask if you need any help on the issue. Maybe we will put runtime-mesh-colliders on our roadmap for future updates, so that users won't need to write any additional code to achieve this.

    [1] http://forum.unity3d.com/threads/32467-How-to-update-a-mesh-collider
    [2] http://answers.unity3d.com/questions/171571/dynamic-mesh-collider.html
     
  17. Pixelcloud-Games

    Pixelcloud-Games

    Joined:
    Apr 29, 2011
    Posts:
    160
    If I understand you correctly, then yes - you could create MeshColliders with 2D ColliderGen in the editor and then enable/disable them at runtime to achieve some of the runtime-goals that you might come up with.
     
  18. Pixelcloud-Games

    Pixelcloud-Games

    Joined:
    Apr 29, 2011
    Posts:
    160
    Maybe I should announce this right away, just to keep you guys up to date:

    There will be built-in runtime support for SimpleSprite sprite animations in the very near future (planned to be included in the upcoming update, if everything goes well). Along with that, Orthello's animated sprites won't be far from being supported as well - just a matter of time. Hope you like it :)
     
  19. Pixelcloud-Games

    Pixelcloud-Games

    Joined:
    Apr 29, 2011
    Posts:
    160
    For those of you who use the 2D ColliderGen Extension with SmoothMoves:

    First of all: thanks for purchasing it, you are awesome! :D

    We have just finished support for the new SmoothMoves 2.2.0 version - something with BoneAnimations was broken in 2D ColliderGen with this release.
    The package is not released officially yet, but if you already own 2D ColliderGen - drop me a message and you get the files for the update ahead of time!

    Cheers, Harald
     
  20. Ocid

    Ocid

    Joined:
    Feb 9, 2011
    Posts:
    476
    Hey Pixel.

    Thanks for the response. I'm looking at opening up mods for something I'll probably be starting work on next month. On the off chance someone actually makes something for it I'd like to either be able to let them choose from a bunch of pre-determined colliders, use their own or have 2D ColliderGen generate one for them.

    I don't see the overall shape being complex given what its based on. I'll still pick this up next month when I start to and see what I can do as it still looks like a neat tool to have.
     
  21. Pixelcloud-Games

    Pixelcloud-Games

    Joined:
    Apr 29, 2011
    Posts:
    160
    Great to hear! If you need any help, just ask.
     
  22. sabba2u

    sabba2u

    Joined:
    Feb 3, 2012
    Posts:
    42
    How about generating box colliders between the points since mesh colliders don't play well with each other as an option. So instead of generating 1 mesh collider, it will create 10 box colliders (thin).
     
  23. G-S-Pratap

    G-S-Pratap

    Joined:
    Apr 29, 2013
    Posts:
    4
    Hi, I have gone through this topic and the 2D collider gen is such a great tool for my game.

    But i would like to know, can i use this tool with SpriteManager, Because i am using the spritemanager for my first 2D game.
    If it supports SM2 then i am ready to buy it. Please give me confirmation asap.
     
  24. Pixelcloud-Games

    Pixelcloud-Games

    Joined:
    Apr 29, 2011
    Posts:
    160
    We have collider-splitting on our roadmap to support concave vs. concave mesh collisions.
    But thanks a lot for the idea, I must admit I haven't thought about this beforehand! Maybe we'll implement this as a quick workaround until splitting is done!

    BTW: About thin colliders, just in case you didn't think about that already: I don't recommend making box colliders too thin, otherwise problems with discrete collision detection might occur..
     
  25. Pixelcloud-Games

    Pixelcloud-Games

    Joined:
    Apr 29, 2011
    Posts:
    160
    Thanks a lot for considering our tool! Unfortunately SpriteManager 2 is not officially supported yet, at least no runtime-animated-colliders. Support for animated colliders for SimpleSprite will be included pretty soon, but we have not yet checked SM 2. I'll talk to the creator of SM 2 about it, maybe we'll include this along with the upcoming SimpleSprite update already.

    With the current version you can create non-animated colliders for your sprites if this is of any help. It might be necessary to manually set the "custom image" parameter for each of your SM2 sprites to point to the desired single-frame-image instead of a texture atlas.
     
  26. Pixelcloud-Games

    Pixelcloud-Games

    Joined:
    Apr 29, 2011
    Posts:
    160
    I have now checked the SpriteManager2 framework about collider generation - good news: we'll implement support for it, it's on the schedule now!
     
  27. Pixelcloud-Games

    Pixelcloud-Games

    Joined:
    Apr 29, 2011
    Posts:
    160
    2D ColliderGen v1.1 has been released on the asset store today. Changes are:

    Compatibility:
    - This version is compatible with SmoothMoves V2.2.0 again.
    (Fixed BoneAnimation problems introduced with this
    SmoothMoves version - member variables have changed.)

    New Features:
    - Added support for OTTileMap. There is now a menu entry
    "2D ColliderGen/Orthello Specific/Add AlphaMesh Colliders To OTTileMap".

    Bugfixes:
    - Previously the bottom-left pixel was not included in the
    outline of objects. This lead to an incorrectly bevelled
    bottom-left corner at a square box (and the outline had
    5 vertices instead of 4).

    - Fixed a bug with Alpha Opaque Threshold not being
    synchronized across all instances of a collider-group.
     
  28. nazavala

    nazavala

    Joined:
    Sep 21, 2012
    Posts:
    2
    Hello Guys
    I purchased this tool and I already added some colliders to my smoothmoves character and the ground that I also created with 2d Tool Kit, so I added the Rigidbody to my character but even so, when I run the game my character is not colliding with the ground, so I checked that both(the Ground and the Character) had the convex option enabled, but even so they are still not colliding so I don't know what is going on, Could you please help me to check this issue.


    Thanks
     
  29. Pixelcloud-Games

    Pixelcloud-Games

    Joined:
    Apr 29, 2011
    Posts:
    160
    Thank you very much for purchasing our tool!
    Two things come to my mind that might lead to this problem:
    1) Does the Rigidbody have the "kinematic" flag ticked? This should be unticked, remember the statement "Kinematic Rigidbodies are not affected by forces, gravity or collisions." on the unity physics manual page.
    2) Is any one of the two objects really convex? Only declaring them as convex when the objects are in fact concave could lead to unexpected behaviour (at least if the collision mechanics are implemented the way that I think they are). You can set the "Force Convex" parameter in the AlphaMeshCollider component so that the mesh is guaranteed to be convex. However, don't forget that you still have to tick the "Convex" parameter at the Rigidbody component, too.

    Apart from that, did you attach the Rigidbody component to a GameObject node in the hierarchy above (=parent) the MeshColliders, or to each individual collider GameObject?

    I suggest that you add a BoxCollider to the objects that have non-working MeshColliders attached and see if the BoxColliders are working. If not, then it's most likely a problem with the Rigidbody settings (e.g. "Is Kinematic"). If the BoxColliders collide well without modification, then i guess that it's a problem with the concavity/convexity of the colliders.

    Please tell me how this little test turns, I hope to be able to help you better then.
    Maybe please also tell me what exactly you want to do with the colliders / what you intend to use them for (e.g. "collide the foot-gameobject with the ground for walking").

    Kind regards,
    Harald
     
  30. Copywright

    Copywright

    Joined:
    Apr 17, 2012
    Posts:
    21
    Would it be possible to generate box colliders, too? This would cut down time on using colliders for tk2d animations.
     
  31. Pixelcloud-Games

    Pixelcloud-Games

    Joined:
    Apr 29, 2011
    Posts:
    160
    This seems like a nice idea, and it's definitly possible, just takes some time to implement. I'll put it on the roadmap (after supporting animated sprites as discussed above).
     
  32. Pixelcloud-Games

    Pixelcloud-Games

    Joined:
    Apr 29, 2011
    Posts:
    160
    I just fixed a bug if you use SmoothMoves together with SpriteManager2: In the current 2D ColliderGen version there is a problem when trying to add an AlphaMeshCollider to a SmoothMoves Sprite object (BoneAnimations are fine). It's due to a name clash between the Sprite classes of the two libraries, the bugfix will be included in the next update.

    If you need it earlier, just drop me a message.
     
  33. G-S-Pratap

    G-S-Pratap

    Joined:
    Apr 29, 2013
    Posts:
    4
    This might be good news for all, and i will wait for the new update.
     
  34. bitwalk

    bitwalk

    Joined:
    Dec 19, 2012
    Posts:
    2
    Hey! Looks like a promising product! Do you have any plans to support NGUI sprites? Preferably in atlases, since I assume if I reference textures in custom images they'll get included in builds even though I actually use an image from an NGUI atlas.
     
  35. Pixelcloud-Games

    Pixelcloud-Games

    Joined:
    Apr 29, 2011
    Posts:
    160
    Hi! Thanks! I must admit that I have not used NGUI before, so I cannot tell how much effort it would be to support it. Could you please tell me what you have in mind, since I don't see many applications where precise colliders are needed in a GUI, but maybe I'm getting things wrong. Thank you!
     
  36. bitwalk

    bitwalk

    Joined:
    Dec 19, 2012
    Posts:
    2
     
  37. Pixelcloud-Games

    Pixelcloud-Games

    Joined:
    Apr 29, 2011
    Posts:
    160
    Are you planning to use animated NGUI sprites? Or just static ones?
     
  38. G-S-Pratap

    G-S-Pratap

    Joined:
    Apr 29, 2013
    Posts:
    4
    Hi Nice work,

    Can i use this tool with normal unity textures with out using any third party tools like 2dtoolkit and more, if so can u guide me on how to implement it with normal unity textures.

    Currently i am using alpha textures with uneven surfaces and the texture moves using the texture offset technique.
     
  39. Pixelcloud-Games

    Pixelcloud-Games

    Joined:
    Apr 29, 2011
    Posts:
    160
    Thanks! Basically yes, you can attach an AlphaMeshCollider component to any game object which will by default use the normal texture of the GameObject for collider computations. You can also set a custom image in the parameters of an AlphaMeshCollider. You can read more about that on our website [link].

    If I understand you correctly, then this might require a bit of additional work to make the colliders follow your texture at runtime. Please note that in the current version of 2D ColliderGen, multiple "collider-islands" (disjoint opaque regions) within a single image are not yet supported - by now it will take the largest island automatically. However we're working on multiple islands support, it will be included in one of the oncoming releases. In the meantime a workaround is to add additional GameObjects and attach an AlphaMeshCollider with a custom image for each collider-island.

    Are you deforming the texture visually with your UV-animation, or is it always the same when viewed from above? If it's defoming, you might need to change the MeshCollider each frame as well. Runtime updates could be acomplished with the 2D ColliderGen API, but require some additional coding (and are not very practical performance-wise on a update-each-frame basis). If you really want to do this, feel free to contact me if you need any help.
     
  40. ramalafritz

    ramalafritz

    Joined:
    Dec 27, 2012
    Posts:
    2
    hi,

    when I use smooth moves and make a simple scaling animation and use collidergen to make the collider it works but when the animation runs the collider mesh isn't scaling with the animation of smoothmoves it always stays the same.
    this seems to be a real problem, please could you check on that I am on collidergen 1.1 and smoothmoves 2.2.4

    best,robert
     
  41. Pixelcloud-Games

    Pixelcloud-Games

    Joined:
    Apr 29, 2011
    Posts:
    160
    Hi Robert,

    Thanks for your hint.
    This has actually been a (soon to be changed) design decision, since SmoothMoves attaches its box colliders in a non-scaling way, too. In fact, it attaches the collider to e.g. the 'Body' node instead of the 'Body_Sprite' node, which handles scaling of the image.

    I will add an additional parameter which lets you choose whether you want to scale the MeshCollider along with the sprite image. If you send me your email, I will provide you with the update as soon as i fixed it (I would like to include some more updates in the next official release).

    Kind regards,
    Harald
     
  42. Pixelcloud-Games

    Pixelcloud-Games

    Joined:
    Apr 29, 2011
    Posts:
    160
    Just finished implementing this feature. Colliders attached to SmoothMoves BoneAnimation sprites can now scale along with it. Added an AlphaMeshCollider toggle parameter "SmoothMoves Scale Anim" to enable this behaviour.

    This feature will be included in the next update, drop me a message when you need it earlier.
     
  43. ramalafritz

    ramalafritz

    Joined:
    Dec 27, 2012
    Posts:
    2
    cool that's great news
     
  44. gaiomed

    gaiomed

    Joined:
    May 5, 2013
    Posts:
    48
    I tried you feature, but it doesn't seem to be correct the colliders are too small, yet not sure why. Smooth Moves has 2 scales a transform and an image scale, I just use the image scale and the transform stays one, if I turn the option on it sort of does something correct nevertheless stays way too small..
    and ramalafritz is actually an other account of mine, so it's me,rob
     
    Last edited: Jul 18, 2013
  45. Lachee1

    Lachee1

    Joined:
    Aug 21, 2012
    Posts:
    16
    Is it possible to generate colliders at runtime?
     
  46. Pixelcloud-Games

    Pixelcloud-Games

    Joined:
    Apr 29, 2011
    Posts:
    160
    I was not able to reproduce you problem, I checked with the latest SmoothMoves version from the Asset Store and the Rise Of the Dough scene contained therin. I tried both changing the image-scale of the bones as well as the transform-scale in the animation editor - both worked as expected.

    Do you use the latest version of SmoothMoves? Have you checked that you did not set the AlphaMeshCollider parameter "Advanced Settings->Custom Scale" to anything smaller than 1?
    If yes, could you tell me if the MeshCollider is attached to the <BoneName>_Sprite node instead directly to the <BoneName>?

    I will send you a pm with the latest dev-package, maybe it helps.
    If the problem persists, could you somehow send me a small version of your scene/project, then I could help you better.

    Kind regards HTH
    Harald
     
  47. Pixelcloud-Games

    Pixelcloud-Games

    Joined:
    Apr 29, 2011
    Posts:
    160
    Hi Lachee,

    In general: yes - You could use functionality contained in the plugin to calculate a polygon fence for a given image at runtime, but you would have to write some code for this yourself at this time (at the current time we have no convenience-script included to support this without any coding). The plugin provides methods such as BinaryAlphaThresholdImageFromTexture(), TriangleFenceOutlineFromBinaryImage(), etc, that could be used for your purpose.

    What exactly do you intend to do? Is it rather like generating colliders once at level-loading, or updating colliders each frame?

    If you need any information on modifying MeshColliders at runtime, you could have a look at these forum posts here [1] [2]. On my desktop pc [3] I can recalculate the collider of a 256x200 image about 100 times per second (with room for optimization, through using multiple threads, etc). The Unity engine itself could come with some performance-limitations regardless of the collider-computations, so we suggest that you try out changing a MeshCollider's (dummy-)Mesh at runtime first to see if this alone fits your performance requirements (such that it's not too costly to recalculate any PhysX stuff..).

    If it does, feel free to cantact me if you need any help on the issue - I will definitly send you the latest dev-package which shall help you a lot. Maybe we will put runtime-mesh-colliders on our roadmap for future updates, so that users won't need to write any additional code to achieve this.

    Hope this was of any help for you!

    Kind regards,
    Harald

    PS: nice avatar :)

    [1] http://forum.unity3d.com/threads/32467-How-to-update-a-mesh-collider
    [2] http://answers.unity3d.com/questions/171571/dynamic-mesh-collider.html
    [3] Running at 3,3 ghz, using a single one of six cores.
     
  48. gaiomed

    gaiomed

    Joined:
    May 5, 2013
    Posts:
    48
    hi,

    thx for your help, I finally debugged the reasons, and it's a combination of problems.

    First problem is when your sprites (pngs) are bigger than the tex size of the smoothmoves atlas it resizes it and that messes up something. I guess smoothmoves reduces the size in the atlas but draws it in original res as the sprite would be in original, that would explain why this happens. I made the atlas big enough and then it worked. Magic, Yeah !!!

    Second problem, smoothmoves allows for having a different pivot in the animation sprite then in the atlas, if this is the case, then your collidershape will be offseted by this and don't align anymore.

    Probably you can easily reproduce this, otherwise I am happy to supply you with a sample project. You might be able to get those things fixed I guess, they don't happen for many people I guess but if they will be quite frustrated as me spent half a day jerking around...not your fault though...

    Thx for the fast and professinal help...
    If I now get done what I wanted I star u on the store !!
     
    Last edited: Jul 19, 2013
  49. Pixelcloud-Games

    Pixelcloud-Games

    Joined:
    Apr 29, 2011
    Posts:
    160
    Hi,

    Thanks very much for figuring that out, that's a great help! I will get working to fix this issue, tell you when it's done!

    Thanks, that would be great! :)
     
  50. Pixelcloud-Games

    Pixelcloud-Games

    Joined:
    Apr 29, 2011
    Posts:
    160
    Finally I fixed the SmoothMoves scaling problem, please take a look at your inbox.
    Along the way I've fixed a pixel-precision issue with texture atlases (affecting SmoothMoves and Orthello atlasses) in general. If the frame-border goes through a pixel instead of being at the border (and thus a half-pixel is visible) it now creates a perfectly precise collider-outline around half-pixels as well!

    If anyone would like to receive this intermediate bugfix-package, just drop me a message!
    Cheers,
    Harald