Search Unity

2D Animation Preview Packages

Discussion in '2D Experimental Preview' started by rustum, Mar 14, 2018.

  1. GameDevCouple_I

    GameDevCouple_I

    Joined:
    Oct 5, 2013
    Posts:
    1,743
    No I understand that I need to have each part on a layer. But why is it PSD support instead of PNGS? It makes sprite swapping even through code pretty much impossible right now...

    Anyway for now we will continue using spine by esoteric, but I am hoping that this becomes more widely usable sooner so that we can switch to it, I hate using external runtimes when I dont have to.

    EDIT: also when I tried to import the PSB using PSD importer, it flattened the image and gave me no way to unflatten it.

    What is the general process to getting a layered PSD in with parts correctly? I followed the guide but it just imports as a flat image with no way to determine what part is what
     
    EvOne likes this.
  2. LilGames

    LilGames

    Joined:
    Mar 30, 2015
    Posts:
    180
    Yes, it flattens to a sprite atlas, since that's how game engines prefer 2D assets. You can still "access" the individual sprites, as with any sprite atlas, view the atlas or view it in "pose mode" as you should have had it in your PSD layers.

    Select the character gameObject (that the PSD importer creates) then in the inspector click Sprite Editor. your first view is "flattened" parts (the atlas), but select "Skinning Editor" from the upper left drop-down and you should see your character's layer parts in the exact same position as you had it in the PSD.

    The big question you are rightfully asking though is HOW to swap individual sprites. That's something many are asking for in other forum discussions about the new 2D Animation package
     
    GameDevCouple_I likes this.
  3. Th0re

    Th0re

    Joined:
    Sep 4, 2015
    Posts:
    32
    Hi,

    I have quite some experience with 2D skeletal animation, including the old-school way of just parenting with pivots. I also used Anima 2D and Puppet 2D.

    My Workflow & Setup
    Import from PSB is excellent. In the sprite sheet, I put all the sprites into a group called “Skin” and import them with the group option on. Then, I name the root bone “Skeleton” (the spine). Both of that goes under the actual agent Holder game object (which carries animator, colliders, most scripts). I also create a “Control” under the Holder, add the IK manager to the skeleton, and create limb solvers. I put them under this new “Control” object, delete each their childs and set each to be their respective targets.

    In result, the Holder has now three children: the Skeleton holds the bones and functionality, Skin holds the appearance and Control harbours the IKs, and is for animation, which I think is also the paradigm used.

    Problems & Inconsistencies
    I found it better to separate some parts of the characters that are better animated separately (like the face, where sprite swap animations make sense). Or parts that are “attached” and don’t need to be part of the core skeleton rig. I have these sprites on a separate sheet.

    1. Problem: Unfortunately, such “skin” objects need to be dropped into the skeleton hierarchy again, ruining the neat separation set up before.
    2. Problem: to rotate the head and to animate the body, I need to animate the skeleton bones directly, which also blurs the separation between skeleton and animation controls.

    Suggestions

    Both of these problems may have a similar solution, and perhaps this exists already (please, let me know!)
    1. Solution: a component that allows a game object to be 'hooked up' to a bone and treated AS IF it was its child. That way, additional sprites or bind/mount objects can be kept separate from the often intricate skeleton hierarchy.
    2. Solution: Puppet 2D has a "parent control" that imposes its position and rotation onto a target bone (intended for root bone), turning a game object into a control target similar to IK objects. So that you can animate this target object and the bone follows directly. Similar to that, an "orient control" that imposes only its rotation to the target bone, turning it into a knob to control a bone's rotation only. That way, targets can be animated consistently without dealing with the skeleton hierarchy.

      Edit: this can be done at least for a rotating part with the CCD Solver2d. You can set it to chain length 1 and toggle the Constrain Rotation.
    Root Rotation Problem
    The root bone, effectively the spine that starts from the hip and goes to the neck starts with a 90° rotation. Since this rotation is at the root, this caused some headaches with the stuff that effectively has to follow the bones (like the additional sprites). I solved this, but I would prefer if it was possible to zero out the root bone rotation, and not start the whole rig 90° rotated.

    Other than that, great system, so far easy to use, and the best I've tested so far, because of the good import and clean setup (as well as copy pasting) of the bones. /Sorry for the Wall of Text ;)
     
    Last edited: Jul 10, 2019
    GameDevCouple_I and EvOne like this.
  4. SamfinacoLimited

    SamfinacoLimited

    Joined:
    Aug 6, 2018
    Posts:
    2
    Hi,

    I face the problem with memory leak on iOS when there is active gameObject with SpriteSkin in my scene.
    Using latest version of 2D Animation 2.0.0-preview.3, tried Unity 2018.3.8, 2018.4.0.

    Is there any workaround for this issue?
     
  5. YD_JMysior

    YD_JMysior

    Joined:
    Aug 4, 2016
    Posts:
    21
    Hello everyone,
    this package looks very promising/exciting. Two questions:
    1. What is its current state? Is it production ready? In other words, would it be reasonable to make animations for a game that is supposed to be released to Nintendo Switch, PS4 and Xbox One in about 5-6 months?
    2. Will new versions of the package be backwards compatible? If not, should we expect redoing all the animation assets from scratch with every new release?
    Thanks in advance
     
    EvOne likes this.
  6. Rafarix

    Rafarix

    Joined:
    Jan 29, 2018
    Posts:
    7
    I haven't been using it too much but as far as I know it seems to be working well enough. I do not know about making games for the consoles, but here is my current experience with this: Animations are pretty easy to make as it fills in the in between frames itself. You just need to add in the key frames and sometimes make a few adjustments in between, but other then that it does most of the work for you. You DO NOT have to redo animations whenever you update to a newer version.

    The only real inconvenience I found is I don't think you can't "reuse" animations for other characters. Such as if you have a walk animation for the player you'll have to remake it for enemies even if they have nearly the same proportions. I do not know if this was updated. Also when you make changes to a character you made animations for depending on how big of a change you might have to redo all the animations.

    There was also a bug where it messed up the tile pallet I posted sometime ago but they fixed that issue - Thanks for that fix btw!
     
  7. Th0re

    Th0re

    Joined:
    Sep 4, 2015
    Posts:
    32
    I could re-use animations, but I specifically designed the rig to be used for other characters. It all depends how you do it, exactly, but when the skeleton is the same, and you animate IKs, it should work. I have yet to test more, and it’s unnecessary complicated to switch skins and make adjustments, but it can work in principle.
     
  8. MathiasNC

    MathiasNC

    Joined:
    May 8, 2019
    Posts:
    1
    Is it no longer possible to use without Photoshop to create psb/psd files?
    When I try to rig a sliced PNG file I'm unable to connect bones on different sprites to eachother using the parenting tool. If I use a non-sliced sprite sheet, I can add bones, but not layer each component of the body correctly

    using animation preview package 2.1 in unity 2019.1
     
    Last edited: Jun 8, 2019
    mangapinches likes this.
  9. Th0re

    Th0re

    Joined:
    Sep 4, 2015
    Posts:
    32
    Last edited: Jun 10, 2019
    LilGames likes this.
  10. Rafarix

    Rafarix

    Joined:
    Jan 29, 2018
    Posts:
    7
    One thing I do which probably not a good idea in the long run, but works is I use GIMP. I would export the file as a .psd, then go to the file and rename the extension to .psb as GIMP cannot export to .psb. There probably is a better way to do this, but it works for me since I don't have photoshop
     
    mangapinches likes this.
  11. felipebarros2010

    felipebarros2010

    Joined:
    Jun 22, 2019
    Posts:
    4
    Hey, Im having the same issue here. Did you figure out how fix it?

    Thks
     
  12. Rafarix

    Rafarix

    Joined:
    Jan 29, 2018
    Posts:
    7
    From my small experience with this based on the screen shot provided try having "Create Bone" or "Edit Joints" selected to remove bones. If you have it on "Preview Pose" or "Reparent Bone" you cannot delete any bones on your sprite.
    UnityEditor.PNG
     
  13. mangapinches

    mangapinches

    Joined:
    Apr 2, 2019
    Posts:
    4
    I have been creating my art in ClipStudio, a manga and animation program. It can only export PSD and PSB as a single layer...so it fails when trying to slice the separate layers in the Sprite Editor. I have tried with separate pngs but then the peices are all separate in the Skinning Editor. Maybe the best solution will be to ask ClipStudio for a multiple-layer export option...

    I just downloaded GIMP and going to give it a try. Hopefully there will be a way to use pngs...I can't really afford Photoshop right now.

    Any solutions are appreciated. Thanks!
     
  14. mangapinches

    mangapinches

    Joined:
    Apr 2, 2019
    Posts:
    4
    UPDATE: So I was able to manually create the layers from the different images in GIMP, then export as PSD. Manually changed extension to PSB. When importing to Unity version 2019.1.8f1, the imported file was able to rig and bones worked fine. However, I got a message that says "File's Layer ID is not unique. Please report to devleoper. 0 <InsertLayerName::InsertOtherLayerName> UnityEngine.GUIUtility : ProcessEvent(Int32,IntPtr)

    Also getting:
    Sprite "SourceFilePSB_0" contains bone weights which sum zero or are not normalized. To avoid visual artifacts please consider fixing them."
     
  15. Th0re

    Th0re

    Joined:
    Sep 4, 2015
    Posts:
    32
    I saved out the .psb asset to .psd to use it in Procreate to touch it up a little. Then exported the whole thing back as .psb with the same arrangement and layer names. That destroyed the rig for good. :confused:

    I conclude that a psb file cannot be replaced, even when the new file is identical in content and naming.


    Some game objects showed "Missing (Sprite") in Sprite Renderer. Oddly enough, the sprites actually exist in the project folder, just as before (naming and all). When dragging them back into the Sprite Renderer component, they show up in the scene, but are misaligned, and don't animate with the bones.

    It was not possible to undo these changes, restart to have changes undone, or simply put back the original file (I did back that up). As far as I can tell, it obliterates the rig entirely.

    After investigating, the element within the psb asset in the project folder of a broken part shows the message below in the inspector. It appears related to the ESC or SubScene workflows. I have no idea what it means, and there is also no such "GameObjectEntity" component on this element or anywhere else to find. Here is what it says.

    If anyone has an idea how to fix it, please let me know.
     

    Attached Files:

    Last edited: Jul 10, 2019
  16. Markstam291

    Markstam291

    Joined:
    Mar 23, 2015
    Posts:
    6
    Hello all!
    I want compine Skeletal 2D Animation with collider - rigidbody, so how to auto generate collider rig - collider on each bone?
    have any video tutorial?
    please help me, thanks!
     
  17. Cientista73

    Cientista73

    Joined:
    Apr 21, 2017
    Posts:
    5
    Hello,

    Does anyone have a workaround for swapping sprites or a estimate when this feature would be supported ? Would It be possible for example to layer multiple sprites for the head so I could enable/disable them ? My game really depends on this feature.

    Thank you
     
  18. Th0re

    Th0re

    Joined:
    Sep 4, 2015
    Posts:
    32
    Here‘s a script by Kamyker, maybe that does the trick. “Simple Scriptable Object that allows overwriting bone, mesh, weights data across sprites.”

    Another way: You can set up a skeleton, and copy that over to a new sprite sheet, hook it up there. It’s reasonably fast, unless you need a lot of fine tuned deformation or extraneous parts that differ between characters.

    If you have a simple rig, you can also do it the old school way. Create a skeleton with no skin (e.g. disable the sprite renderers). Then prepare your sprite “skin“ by setting the pivots on each sprite part. Next, drop the respective part directly under each bone. If that puppet works, you can swap out the sprites in their sprite renderer component of each game object, change all parts, or just some. But it‘s not automatic. You can make it more fancy by storing the collection of sprites in a scriptable object, and write an editor script that loads these and applies them. It used to be possible to copy the meta file of the sprite sheet, and given an identical sprite sheet setup, carry over the pivots — maybe that still works, which simplifies some work.

    Another way to help with the pivots is to drop each sprite part first into an empty game object, zero local transform, and then arrange this object under the bone. It‘s then possible to drop another sprite into this “container” and it should sit correctly (provided that the sprites are not too different in their proportions).
     
    Cientista73 and EvOne like this.
  19. EvOne

    EvOne

    Joined:
    Jan 29, 2016
    Posts:
    58
    It seems that in Unity 2019 this script is no longer working. I could not find a using directive that would remove these errors :(

    2019-07-14_09-55-23.png
     
  20. tpun

    tpun

    Joined:
    Jul 15, 2019
    Posts:
    1
    I've downloaded the samples, did what you suggested and it doesn't work in 2.0. If anyone has any suggestions please advise.
     
  21. tweedie

    tweedie

    Joined:
    Apr 24, 2013
    Posts:
    269

    If you want FFD, unfortunately you can't just parent the sprite to the bone, and you cant just swap the sprite out on the renderer, because then it'll complain about no binding / mesh info (which is why I've repeatedly asked if it would be possible to separate that data out from the sprite itself, it seems incredibly limiting this way).

    If you need anything beyond simple bone rotation, you can either:

    - Write the MeshData from a base sprite in the PSB to a new sprite, but that'll require either using some third party code like the github page linked above, or digging through the framework yourself.
    - Swap the skeleton's materials out for a custom shader which doesn't use _MainTex as the "drawn" sprite. However, for any sprites that are packed to an atlas, this will require you undo the base sprite's RectOffset / UV mapping and reapply the UVs necessary for the new sprite, which in turn means your replacement sprites should have the same aspect ratio as the base sprites and have the same relative scale to their canvas (meaning you could have a lot of wasted transparency, and your meshes need to be large enough to accommodate any sprite you give it, so your overdraw could increase too).

    We opted for the second route because I'm expecting the API to shift under our feet for the foreseeable future and didn't want to write tooling that's gonna break a couple of months from now. Overdraw on characters also isn't a big concern for us. This method isn't especially efficient but, I think, is the most flexible and easy enough to change down the line (no custom data on sprites, doesn't require the replacement sprites to be in a rig etc).
     
    Cientista73 and EvOne like this.
  22. K0ST4S

    K0ST4S

    Joined:
    Feb 2, 2017
    Posts:
    3
    Bug: character bone handles disappear after first Play.

    Questions:
    Can I make a prefab out of rigged .psb file? If I do, I get "Sprite has no Bind Poses" error later.
    How to edit default pose?

    Version:
    2D IK: preview.1 - 1.0.1
    2D Animation: preview1 - 2.2.0
     
  23. Rafarix

    Rafarix

    Joined:
    Jan 29, 2018
    Posts:
    7
    It can, but it's a bit tricky.

    From what I have experienced if you touched up on a sprite you want to update such as something minor like a color change to safely replace it DO NOT drag and drop the .psb file into unity.

    Instead try this:
    1) Save and close unity
    2) Find and open the folder to where the sprite you are updating is
    3) Copy and paste the new sprite into the folder and choose yes to replace
    4) Reopen unity and check the sprite it should still be there fine.

    I should note that this works best if there is no new object that is not attached to any of the old sprite; such as a sword that is detached and the character never had before. As the new object may not appear if your sprite is already made in the scene, and is at least to me more finicky to add in.
     
    EvOne and Th0re like this.
  24. edrache

    edrache

    Joined:
    Nov 14, 2012
    Posts:
    1
    Hi, I have problem with IK and LimbSolver. I've made a skeleton and when I used LimbSolver one bone rotates in 3d. I removed this bone and created another one in the same place (almost) and now it worked.

    I've prepared Project with this issue and here is youtube video with my problem:


    You can download a simple project with a test scene here:
    https://my.pcloud.com/publink/show?code=XZMWpv7ZegPNnws7Un7GCFdjXxBLo5KbXTPy

    Or download attachment.
    What is wrong with bone 'Body'? Is it me or is it a bug? :)
     

    Attached Files:

  25. Th0re

    Th0re

    Joined:
    Sep 4, 2015
    Posts:
    32
    Somewhere above, I looked for a solution to hook up additional game objects (sprites) to bones, without having to drop them into the bone hierarchy as children — similar to how it’s done automatically with the “skin” sprites. I found out about the constraint component, which may be useful for others as well. https://docs.unity3d.com/Manual/Constraints.html
     
    mountblanc and EvOne like this.
  26. pyst1996

    pyst1996

    Joined:
    Dec 5, 2018
    Posts:
    2
    I have many photos and I want to create animation based on existing photos, how should I do it, help me!
    upload_2019-7-31_20-11-13.png
     
  27. komoka

    komoka

    Joined:
    Jun 22, 2013
    Posts:
    1
    Is it/will it be possible to use this in screen space?
     
  28. Rafarix

    Rafarix

    Joined:
    Jan 29, 2018
    Posts:
    7
    It's kind of hard to explain but this video that was posted here earlier gives you a good rundown on how to use the 2d animation package.


    I assume your image is a horse rider just sitting idle. What I would suggest is any limbs you want to move they need to be on a separate layer for example the horses tail as it moves from one side to another should be alone on its own layer so you can attach a bone to it and move it without influencing any other parts it shouldn't.

    Also in the video I do find .psb files the best way to utilize 2d animation, and if you do not have photoshop what you can do is use a free image editor such as GIMP or Krita save/export to a .psd file and change the extension manually to .psb
     
  29. CoCoNutti

    CoCoNutti

    Joined:
    Nov 30, 2009
    Posts:
    486
    Yes, I use Illustrator for all my art.

    So in illustrator, export to Photoshop file (PSD).
    Then in Finder, rename that exported file to have the PSB extension.
    Import it into Unity, with User layer grouping ticked
    Hey presto! ;)


    Some Illustrator tips I discovered using the above technique:
    In Illustrator, it doesn't like (for me anyway) to have each piece on an individual layer. Rather, I had all pieces of the character on ONE layer and each item was named eg Leg_Left, Leg_Right, etc. Also, it seems to hate nested groups.
     
    Last edited: Aug 16, 2019 at 4:33 PM
  30. CoCoNutti

    CoCoNutti

    Joined:
    Nov 30, 2009
    Posts:
    486

    I had this same issue tonight - lost the entire rig >< >< >< The above process, whilst might work, isn't a great solution though. I mean, you should be able to update sprites without losing all of your work. I think this is a bug??
     
    EvOne likes this.
  31. Wecica

    Wecica

    Joined:
    Jul 20, 2016
    Posts:
    24
    I can't preview animations while editing the animation transition in the controller.
    By the way, how could I swap cloth using this skeleton 2d animation?
     
    EvOne likes this.
  32. EvOne

    EvOne

    Joined:
    Jan 29, 2016
    Posts:
    58
    There is a way to change skins, but not by replacing graphics alone :(
    The official version is described in the documentation and (for me) is too time-consuming, which I wrote about in the next forum thread. Here is my post:
    #304
    And here is the answer of the Developer :)
    #309

    But, this way of replacing graphics is... -It seems to me that this is the Wrong Way :oops:
     
    Last edited: Aug 21, 2019 at 2:52 AM