Search Unity

  1. Unity 2019.2 is now released.
    Dismiss Notice

2D Exparamental Features

Discussion in '2D Experimental Preview' started by LastAi, Oct 31, 2019.

  1. LastAi

    LastAi

    Joined:
    Aug 15, 2013
    Posts:
    7
    Let me preface this by saying the ability to swap sprite sheet/atlases on the fly with out complicated or taxing on lateUpdate() calls has been something I have been waiting for since 2014-2015.

    I love the new Sprite Library and Sprite Resolver system.
    https://docs.unity3d.com/Packages/com.unity.2d.animation@3.0/manual/SRComponent.html
    https://docs.unity3d.com/Packages/com.unity.2d.animation@3.0/manual/SLAsset.html

    I have been working with this system and feel like as if the way its currently implemented... doesn't... actually do anything major...
    This system as implemented is more or less a glorified labeling and sorting sprite system.
    And to be fair for joint and skinned 2d character this is helpful...but...

    IT COULD BE AN AMAZING FRAME BASED ANIMATION SYSTEM!!

    So if we take the sprite library and shove all of it up a step.
    It suddenly is extremely helpful.
    (Make individual librarys = category, make the categories = labels, and the labels in to frames.)


    OK. So let me explain.
    We will start with the what is used in the example picture.
    A saber, a bat, a blade, and an axe(although the resolver is missing the axe in the picture).


    Ok so still with me?
    Cool.

    Now. lets turn this upside down.
    I create 4 category.
    1 called Saber.
    1 called Bat.
    1 called Blade.
    1 called Axe.
    Each has the current image and I label it 'Held'.

    Now I want to create some frames for each lets make it simple.
    A Slash and a Thrust.

    So now each of the 4 Category has 3 images, a normal one, Slash, and a Thrust.
    For example I got a image off google of a slashing sword.
    Imagine for a moment that the saber, blade, so one have very different slashes.
    So if now I animate the Sprite Resolver label.

    From Held to Slash.

    A character can be animated Frame based once.
    And now amour, weapons, body parts and any thing else can each have its own Sprite Library Asset.
    And Categories can now be used to set the 'Current' sprite set from that Library.
    The Labels can be used to animate the current frame.




    OK. Still with me?
    Now I'm not completely taking out my ass. I dragged a character from 4 years that never got used since I could never get Sprite sheet swapping to not be resource heavy. Get 8 characters on screen and the whole thing took a hit.
    If you don't know what I mean see the Unity YouTube channel vid here on sprite re-skining with lateUpdate() its possible but not optimal.
    https://www.youtube.com/watch?time_continue=1605&v=HM17mAmLd7k



    So I have some captured footage of me testing this random theory of mine.

    Currently only the front leg was updated in the run animation for testing.
    And yes... that is in fact a pony. Its old and i need something to test with.

    Editor works... great actually....
    Some weird values show up but after flattening the curve it runs smooth in the editor.
    Now, when i run the game, it only half works. it flickers wildly, but if you look carefully you can see that it is still changing frames correctly to the animation, but then snaps back to that locked first frame.
     
    Last edited: Oct 31, 2019
  2. Sam_Ooi

    Sam_Ooi

    Unity Technologies

    Joined:
    Mar 5, 2018
    Posts:
    32
    Hi LastAi, I think you are describing a similar Frame-by-Frame from this example in the docs: https://docs.unity3d.com/Packages/com.unity.2d.animation@3.0/manual/FFanimation.html

    You should also change the Keyframe Tangent setting as well:

    Change the Keyframe Tangent
    When animating with the Category and Label value of the Sprite Resolver in the Animation window, it is important to change the keyframe’s tangent in the Animation window to Constant.



    This is because the Sprite Resolver component uses the defined string hash value to locate the desired Sprite. If the values between keyframe’s are interpolated, the Sprite Resolver will not be able to resolve to the correct Sprite.
     
  3. LastAi

    LastAi

    Joined:
    Aug 15, 2013
    Posts:
    7
    Ah I see.
    I did already Break the curve and set to Constant in my video.
    But I animated with REC button.
    It seems this doesn't produce the same results as shown in the image on that same page.


    Sorry about image quality, currently at work and can only get a snap shot from the poorly compressed video.

    Do these proportys need to be manual added to the timeline?

    Also fun question, Will it be possible to get the same Image based preview on the Dopesheet like with the render for sprite?

    I'll do some more playing a round when I get off of work, the features don't seem to have... any coverage at all online.
    Is this feature still on scheduled to release with 2019.3?
     
  4. LastAi

    LastAi

    Joined:
    Aug 15, 2013
    Posts:
    7
    Ok so i have figured it out.
    The weird issue seem to have been caused by the fact that i am using old animations and adding these new feature to them.

    If I use the Animator component, the animations run, but it generating errors in the console.
    if I use the Animation component they will not run and I get "must be marked as legacy unity"

    After looking this up I was able to find information about animations being legacy.
    So if i take create a new Clean animation. Copy and pasted the keys from the old to the new it runs.


    I didn't realize the animation files had changed.