{"author_link":"\/users\/michael-wingfield","author_name":"Michael Wingfield","author_uid":"michael-wingfield","comments":[],"epoch":1557026130,"event":"LD44","format":"md","ldjam_node_id":156681,"likes":7,"metadata":{"p_key":"132393","p_author":"Michael Wingfield","p_authorkey":"1013709","p_urlkey":"348587","p_title":"Animation Exasperation","p_cat":"LDJam ","p_event":"LD44","p_time":"1557026130","p_likes":"7","p_comments":"0","p_status":"WAYBACK","us_key":"1013709","us_name":"Michael Wingfield","us_username":"michael-wingfield","event_start":"1556236800","event_key":"75","event_name":"LD 44"},"node":{"_collation":{"body_sanitizer":"TextUtils::SanitizeHTML via existing importer","event":"LD44","removed_author":false},"_superparent":139254,"_trust":1,"author":13709,"body":"*(TLDR: I created a sweet script that means I don't have to do 300+ steps for our future game jams, find the link to the script below)*\n\n**Goal:** Add 1 new character to our Isometric Game in Unity\n\n![four-characters.gif](\/\/\/raw\/d85\/3\/z\/249df.gif)\n\n**Steps:**\n\n1. Create sprite strip (make sure all cells are the same width and height)\n2. Import `Texture2D` into Unity\n3. Set `Sprite Mode` to Multiple\n4. Click `Sprite Editor` button (don't forget to save the changes to Sprite Mode)\n5. Click the `Slice` option in the top menu\n6. In the `Type` dropdown, select `Grid by Cell Size`\n7. Enter `16` for width (Pixel size X) and `32` for height (Pixel size Y)\n8. Click the `Slice` button\n9. Repeat steps 1-8 for each direction your character is facing for both `Walk` animations and `Stand` animations (total of 8 sprite strips)\n10. Take a deep breath, because you are not even half way done\n11. Right click your Animation folder in your explorer and create a new `Animator Controller`\n12. Click on your `AnimatorController` and open up the `Animator` tab in the Unity Editor\n13. Right click in your Animation folder again and create a new `Animation`\n14. Make sure to name your `Animation` object based on the sprite sheet it is going to be associated with (DownLeftWalk, DownLeftStand, UpRightWalk, UpRightStand, etc...)\n15. Click and drag the newly created `Animation` into the `Animator` tab window that you have open\n16. Repeat step 13-15 for each of your sprite sheets\n17. Now create an empty `GameObject` in your scene (or you can use a prefab)\n18. Add the `SpriteRenderer` and `Animator` components\n19. Drag the `AnimatorController` from step 11 into the `Animator.Controller` slot\n20. Open up the `Animation` tab (different from `Animator` tab) while you have the `GameObject` selected (that part is important)\n21. Now you *should* have a dropdown in the `Animation` tab that has your list of `Animation`'s, if not, go back to step 20 and try again\n22. Select one of the `Animations` from the drop down\n23. Navigate to the folder you have your actual sprite sheet asset in\n24. Click the little arrow to open up your sprite sheet and show all of the individual sprite frames in the explorer\n25. Shift-Click to select all of the frames out of the sprite sheet\n26. Drag the frames from the explorer and drop them into the `Animation` tab\n27. You should see the frames listed one-by-one in the `Animation` tab\n28. Click the play button in the `Animation` tab to view the animation (don't forget to navigate back to the `Scene` view) and you can now adjust the speed of the animation by changing the `Samples` number in the `Animation` tab\n29. Repeat steps 22-28 for all of your `Animations` for this character\n30. (Optional) Our animations looped, so you need to go into each `Animation` object and select `Loop Time` and `Loop Pose`\n\nNo biggy.  Now just do this entire process 13 times (1 for the player character, and 12 more times for each NPC).\n\n![sheet-example.png](\/\/\/raw\/d85\/3\/z\/249e0.png)\n\nIn total, I spent just shy of 3 hours working on this task for our jam (not including the time to actually make the sprite sheet, that part was done by our artist, or the part where I had to actually LEARN how to make all this stuff work in the first place).  This list, I feel, really highlights the downside to using Unity for our animation framework.  There is just such an incredible amount of overhead to get just a single animation into the game.  And honestly, since we only do this process once every few months, one of us has to relearn it all from scratch each time.  We've probably all, during one jam or another, sat there reading through Unity docs and watching youtube tutorials trying to figure out how to configure everything just right so that Unity will allow us to play our 2D animations.\n\nI'm sure there is a really great use-case for such a complex animation system somewhere in 3D land, but for all of us who are using Unity in just 2 dimensions, we could really use a better process for this. So, after this jam was over, I decided to investigate how it could be done.\n\nAssetPostprocessor to the rescue!\n\nIn Unity, you can set up an Asset processing pipeline where scripts are run when specific types of Assets are imported into the project. After much fiddling, I've found a half-way-decent approach to automate MOST of the busy work.\n\nCheck out my gist to get the full file: https:\/\/gist.github.com\/Kenoshen\/494a83028e8c6509087172c21fefcef4 (put it in Assets\/Editor)\n\nInstead of doing that entire list manually, this script will run every time you import a new sprite sheet into the project.  It slices the texture (given some texture naming conventions), creates the `AnimatorController` and each `Animation`, adds the frames of the sprite sheet into the `Animation`, and adds the `Animation` to the `AnimatorController`.  All together reducing your work down to dragging the appropriate `AnimatorController` into the correct `GameObject` `Animator` component.\n\nIf you were like our team and were constantly battling with Unity's Animation system, I hope this script helps you in your future work.\n\nGood luck and happy Jamming!\n\nPS. Check out our game: [2nd Bank](https:\/\/ldjam.com\/events\/ludum-dare\/44\/2nd-bank)\n\n![hero.png](\/\/\/raw\/d85\/3\/z\/249e1.png)\n\n\n","comments":1,"comments-timestamp":"2019-05-05T04:44:09Z","created":"2019-05-05T02:36:16Z","files":[],"files-timestamp":0,"id":156681,"love":7,"love-timestamp":"2019-05-06T15:01:13Z","meta":[],"modified":"2019-05-06T15:01:13Z","name":"Animation Exasperation","node-timestamp":"2019-05-05T03:15:30Z","parent":139648,"parents":[1,5,9,139254,139648],"path":"\/events\/ludum-dare\/44\/2nd-bank\/animation-exasperation","published":"2019-05-05T03:15:30Z","scope":"public","slug":"animation-exasperation","subsubtype":"","subtype":"","type":"post","version":472213},"node_metadata":{"n_key":"156681","n_urlkey":"348587","n_parent":"139648","n_path":"\/events\/ludum-dare\/44\/2nd-bank\/animation-exasperation","n_slug":"animation-exasperation","n_type":"post","n_subtype":"","n_subsubtype":"","n_author":"13709","n_created":"1557023776","n_modified":"1557154873","n_version":"472213","n_status":"WAYBACK"},"source_url":"https:\/\/ldjam.com\/events\/ludum-dare\/44\/2nd-bank\/animation-exasperation","text":"*(TLDR: I created a sweet script that means I don't have to do 300+ steps for our future game jams, find the link to the script below)*\n\n**Goal:** Add 1 new character to our Isometric Game in Unity\n\n![four-characters.gif](\/\/\/raw\/d85\/3\/z\/249df.gif)\n\n**Steps:**\n\n1. Create sprite strip (make sure all cells are the same width and height)\n2. Import `Texture2D` into Unity\n3. Set `Sprite Mode` to Multiple\n4. Click `Sprite Editor` button (don't forget to save the changes to Sprite Mode)\n5. Click the `Slice` option in the top menu\n6. In the `Type` dropdown, select `Grid by Cell Size`\n7. Enter `16` for width (Pixel size X) and `32` for height (Pixel size Y)\n8. Click the `Slice` button\n9. Repeat steps 1-8 for each direction your character is facing for both `Walk` animations and `Stand` animations (total of 8 sprite strips)\n10. Take a deep breath, because you are not even half way done\n11. Right click your Animation folder in your explorer and create a new `Animator Controller`\n12. Click on your `AnimatorController` and open up the `Animator` tab in the Unity Editor\n13. Right click in your Animation folder again and create a new `Animation`\n14. Make sure to name your `Animation` object based on the sprite sheet it is going to be associated with (DownLeftWalk, DownLeftStand, UpRightWalk, UpRightStand, etc...)\n15. Click and drag the newly created `Animation` into the `Animator` tab window that you have open\n16. Repeat step 13-15 for each of your sprite sheets\n17. Now create an empty `GameObject` in your scene (or you can use a prefab)\n18. Add the `SpriteRenderer` and `Animator` components\n19. Drag the `AnimatorController` from step 11 into the `Animator.Controller` slot\n20. Open up the `Animation` tab (different from `Animator` tab) while you have the `GameObject` selected (that part is important)\n21. Now you *should* have a dropdown in the `Animation` tab that has your list of `Animation`'s, if not, go back to step 20 and try again\n22. Select one of the `Animations` from the drop down\n23. Navigate to the folder you have your actual sprite sheet asset in\n24. Click the little arrow to open up your sprite sheet and show all of the individual sprite frames in the explorer\n25. Shift-Click to select all of the frames out of the sprite sheet\n26. Drag the frames from the explorer and drop them into the `Animation` tab\n27. You should see the frames listed one-by-one in the `Animation` tab\n28. Click the play button in the `Animation` tab to view the animation (don't forget to navigate back to the `Scene` view) and you can now adjust the speed of the animation by changing the `Samples` number in the `Animation` tab\n29. Repeat steps 22-28 for all of your `Animations` for this character\n30. (Optional) Our animations looped, so you need to go into each `Animation` object and select `Loop Time` and `Loop Pose`\n\nNo biggy.  Now just do this entire process 13 times (1 for the player character, and 12 more times for each NPC).\n\n![sheet-example.png](\/\/\/raw\/d85\/3\/z\/249e0.png)\n\nIn total, I spent just shy of 3 hours working on this task for our jam (not including the time to actually make the sprite sheet, that part was done by our artist, or the part where I had to actually LEARN how to make all this stuff work in the first place).  This list, I feel, really highlights the downside to using Unity for our animation framework.  There is just such an incredible amount of overhead to get just a single animation into the game.  And honestly, since we only do this process once every few months, one of us has to relearn it all from scratch each time.  We've probably all, during one jam or another, sat there reading through Unity docs and watching youtube tutorials trying to figure out how to configure everything just right so that Unity will allow us to play our 2D animations.\n\nI'm sure there is a really great use-case for such a complex animation system somewhere in 3D land, but for all of us who are using Unity in just 2 dimensions, we could really use a better process for this. So, after this jam was over, I decided to investigate how it could be done.\n\nAssetPostprocessor to the rescue!\n\nIn Unity, you can set up an Asset processing pipeline where scripts are run when specific types of Assets are imported into the project. After much fiddling, I've found a half-way-decent approach to automate MOST of the busy work.\n\nCheck out my gist to get the full file: https:\/\/gist.github.com\/Kenoshen\/494a83028e8c6509087172c21fefcef4 (put it in Assets\/Editor)\n\nInstead of doing that entire list manually, this script will run every time you import a new sprite sheet into the project.  It slices the texture (given some texture naming conventions), creates the `AnimatorController` and each `Animation`, adds the frames of the sprite sheet into the `Animation`, and adds the `Animation` to the `AnimatorController`.  All together reducing your work down to dragging the appropriate `AnimatorController` into the correct `GameObject` `Animator` component.\n\nIf you were like our team and were constantly battling with Unity's Animation system, I hope this script helps you in your future work.\n\nGood luck and happy Jamming!\n\nPS. Check out our game: [2nd Bank](https:\/\/ldjam.com\/events\/ludum-dare\/44\/2nd-bank)\n\n![hero.png](\/\/\/raw\/d85\/3\/z\/249e1.png)\n\n\n","title":"Animation Exasperation","wayback_source":[]}