Search Unity

Unity Sprite 2D Deformation

Discussion in '2D' started by Neterea Studios, Nov 1, 2014.

  1. Neterea Studios

    Neterea Studios

    Joined:
    May 7, 2013
    Posts:
    23
    Hi,

    I have been looking for a way to deform a sprite created with Unity default sprite system.

    The only tools I have found that let you do something like this on the asset store were full 2d packages with bone animations and free form mesh deformations. The thing is that I only need to deform sprites for static objects that will be at the background, no need to deform them in realtime with bones or have bones that affect performance if I have a lot of deformed objects.

    Do you know of some tool that can do this with Unity default sprite system?

    I found on other threads that some users are trying to accomplish this using UnityEditor.Sprites.DataUtility.GetSpriteMesh in order to deform the internal mesh (with the associated problems of converting the sprite to something that is not a sprite later... as that function seems to be only available in the UnityEditor namespace... no avaible at runtime?). Any luck with this? Do you know is some tool like this is available?

    I know I could create some meshes using regular UV textures outside Unity... but this would make the process of creating the scenes a little bit tedious. There are a lot of objects that are already regular sprites... so deforming them in Unity would be ideal.

    If you think I'm missing something that could help in this... you are welcome!
     
  2. imaginaryhuman

    imaginaryhuman

    Joined:
    Mar 21, 2010
    Posts:
    5,834
    What reason do you need it to be part of the sprite system still? Could you not use a normal mesh with texture, and then also add any 2d physics colliders to it that you need? Or do you depend on some auto-generation or something?
     
  3. Neterea Studios

    Neterea Studios

    Joined:
    May 7, 2013
    Posts:
    23
    Hi and thanks for your interest.

    Well, it's a mixture of things, just to name a few:

    - I find it's nice to just drag a sprite and have a mesh with the configured "Pixels To Units" ratio. This makes easy to have a consistent 2d graphics, as far as texel size on screen is concerned. Of course, if we then could deform this sprite, this PixelsToUnits would be approximate, but ensuring this with normal meshes with manually applied UV textures is far more tedious.
    - I have a parallax setup where z distance is taken into account. So it's again desirable to have a lot of objects at the same z distance, in order to move all of them at the same speed, and control the ordering with "Order in Layer". But meshes are all rendered in the default 0 value, I guess.
    - For consistency! This is just mental sanity... nothing to do with technical issues.

    There are some other small reasons, but they are too small and particular to mention them.

    I will end up doing this with normal meshes and modifying the parallax setup to have a space where z distance is not taken into account, if I don't find a way using sprites. I will investigate how to get "Order in Layer" on normal meshes too to avoid the parallax setup modification.
     
  4. Vitor_r

    Vitor_r

    Joined:
    May 23, 2013
    Posts:
    93
  5. Neterea Studios

    Neterea Studios

    Joined:
    May 7, 2013
    Posts:
    23
    Thanks for pointing to that thread Victor!