Search Unity

Sprite Animation Clipping Mask

Discussion in '2D' started by soundwav_, Nov 14, 2013.

  1. soundwav_

    soundwav_

    Joined:
    Apr 23, 2013
    Posts:
    12
    Hi all,
    I was wondering if there's a way to clip sprites easily in Unity 4.3's new 2D system.

    For example, lets say I have these 2 assets in a sheet:
    $Q1.jpg

    And I want to animate the leaf's rotation inside the green rectangle:
    $Q2.jpg

    I suspect that it's not possible, which means I would need to use a classic spritesheet animation,
    which is too bad, since with Unity's animation system, I could have the leaves animation's "strength" to correspond to how hard the block was falling on the ground, for example... but I thought I'd ask here first :)

    Any ideas would be much appreciated.
    Thanks!
     
  2. soundwav_

    soundwav_

    Joined:
    Apr 23, 2013
    Posts:
    12
    Nobody has any ideas? Bummer...

    I really hope the Unity devs add this functionality (and an overall simple way to do clipping masks in Unity, instead of workarounds using planes and shaders that is difficult to get to work correctly).

    I love Unity, don't get me wrong :) But it seems they simplified a LOT of things, I'm just surprised they didn't simplify that specific aspect.
     
  3. Sinron

    Sinron

    Joined:
    Oct 12, 2012
    Posts:
    16
    I think this may be possible. If you have the leaves be hollow.
    Then in the animation for the leaves have that tile you want them to clip with in the back as they rotate and / or fall.

    Will this give you the desired result?
     
  4. soundwav_

    soundwav_

    Joined:
    Apr 23, 2013
    Posts:
    12
    Thanks for the reply,
    what do you mean by having the leaves be hollow? Thanks!
     
  5. IzzySoft

    IzzySoft

    Joined:
    Feb 11, 2013
    Posts:
    376
    Im a N00b, sorry.

    Im just theorizing.

    Leaf can Rotate around Z?

    Leaf might need a black and transparent Texture Mask, that a custom Shader will use?

    ex:


    Problem: Passing in the Rotation to the Shader and having the shader use that rotation to rotate the Black and Transparent Mask... and offsetting it. I guess the shader needs to be given the mask uv offsets as well.

    I guess you would have to get the Angle... background plane compared to a Leaf and use that for the Masks rotation in the shader?!?

    I have no idea if a shader can rotate masks or how that works... But i would try that way 1st. :/

    maybe use: http://wiki.unity3d.com/index.php?title=DepthMask
     
    Last edited: Jan 6, 2014
  6. StephenRoss

    StephenRoss

    Joined:
    Mar 10, 2014
    Posts:
    1
    You can do this if you use NGUI and just add a panel turn on clipping, then add your leaf as a sprite inside the panel and add a script to rotate it. I would use the spin script as its already made.

    However this only works inside rectangular shapes. I would like to be able to do clipping inside any path shape. I hope they add the ability to do this soon because it would be really helpful if for doing tiled animations inside unity that you might want to clip with an irregular shape.

    I looked into depth mask but it seems way more complicated to do.

     
  7. Kurius

    Kurius

    Joined:
    Sep 29, 2013
    Posts:
    412
    FYI you can also do this with 2Dtoolkit. It definitely works inside rectangular clipping areas, but I haven't tried to create irregular clipping areas yet.
     
  8. AllStarBigBoy

    AllStarBigBoy

    Joined:
    Oct 23, 2014
    Posts:
    1