{"assets":[],"author_link":"author\/local-minimum\/","author_name":"local minimum","cat":"LD #28","categories":["LD #28"],"comments":[],"epoch":1386920820,"event":"LD28","likes":9,"metadata":{"p_key":"81398","p_author":"local minimum","p_authorkey":"0","p_urlkey":"290515","p_title":"Sprite Code for Unity and Desktop Photo","p_cat":"LD #28","p_event":"LD28","p_time":"1386920820","p_likes":"9","p_comments":"0","p_status":"WAYBACK","us_key":null,"us_name":null,"us_username":null,"event_start":"1386892800","event_key":"20","event_name":"LD28"},"source_url":"2013\/12\/13\/sprite-code-for-unity-and-desktop-photo\/","text":"<p><strong>Unity 2D Sprite Animation<\/strong><\/p>\n<p>I spent the warmup weekend cursing the collision detection in the new 2D mode in Unity for several hours until I realized that there was a new OnCollisionEnter2D. Makes sense, but lesson learned: <strong>know your tool before starting<\/strong>. I would have been so frustrated if those hours had been tomorrow afternoon, that I don\u2019t know what would have happened.<\/p>\n<p>After that debacle, I made a <a href=\"https:\/\/www.dropbox.com\/s\/ar2tp62ovzuckyh\/CSharp_Unity2D_SpriteAnimationScript.zip\" title=\"Unity2D Sprite Animation Script\">Unity2D Sprite Animation Script<\/a> that I think turned out pretty nice and easy to use. Probably there are better and more efficient out there, but since we\u2019ll probably use it, it needs to be available. So here you go. If you want to use it, consider it public domain.<\/p>\n<p>Short instructions: Use Unity\u2019s sprite editor to break up sprite sheet(s) into sprites. Then add one SpriteAnimator per type of animation you want on your game object (e.g. \u2018walk left\u2019, \u2018walk right\u2019).<br\/>\nAdd one SpriteAnimationSelector to the game object with the SpriteAnimator(s). The CharacterController is not a full controller by any means, but it shows how to interface with the SpriteAnimationSelector.<\/p>\n<p>Finally, this is where we\u2019ll code, more computers are coming:<br\/>\n<div class=\"wp-caption alignnone\" id=\"attachment_305629\" style=\"width: 310px\"><a href=\"http:\/\/www.ludumdare.com\/compo\/wp-content\/uploads\/2013\/12\/20131213_100958.jpg\"><img alt=\"The living room game making table of the turmeric jam jar.\" class=\"size-medium wp-image-305629\" height=\"225\" sizes=\"(max-width: 300px) 100vw, 300px\" src=\"http:\/\/www.ludumdare.com\/compo\/wp-content\/uploads\/2013\/12\/20131213_100958-300x225.jpg\" srcset=\"http:\/\/ludumdare.com\/compo\/wp-content\/uploads\/2013\/12\/20131213_100958-300x225.jpg 300w, http:\/\/ludumdare.com\/compo\/wp-content\/uploads\/2013\/12\/20131213_100958-550x412.jpg 550w\" width=\"300\"\/><\/a><p class=\"wp-caption-text\">The living room game making table of the turmeric jam jar.<\/p><\/div><\/p>\n<p>And here\u2019s where we\u2019ll try our luck with using stop-motion in making the game:<br\/>\n<div class=\"wp-caption alignnone\" id=\"attachment_305630\" style=\"width: 310px\"><a href=\"http:\/\/www.ludumdare.com\/compo\/wp-content\/uploads\/2013\/12\/20131213_101106.jpg\"><img alt=\"The animation corner of the turmeric jam jar.\" class=\"size-medium wp-image-305630\" height=\"225\" sizes=\"(max-width: 300px) 100vw, 300px\" src=\"http:\/\/www.ludumdare.com\/compo\/wp-content\/uploads\/2013\/12\/20131213_101106-300x225.jpg\" srcset=\"http:\/\/ludumdare.com\/compo\/wp-content\/uploads\/2013\/12\/20131213_101106-300x225.jpg 300w, http:\/\/ludumdare.com\/compo\/wp-content\/uploads\/2013\/12\/20131213_101106-550x412.jpg 550w\" width=\"300\"\/><\/a><p class=\"wp-caption-text\">The animation corner of the turmeric jam jar.<\/p><\/div><br\/>\nAll from our living room.<\/p>\n<p>Tags: <a href=\"http:\/\/ludumdare.com\/compo\/tag\/nocat\/\" rel=\"tag\">#NoCat<\/a>, <a href=\"http:\/\/ludumdare.com\/compo\/tag\/desktop\/\" rel=\"tag\">desktop<\/a>, <a href=\"http:\/\/ludumdare.com\/compo\/tag\/source-code\/\" rel=\"tag\">source code<\/a>, <a href=\"http:\/\/ludumdare.com\/compo\/tag\/turmeric\/\" rel=\"tag\">turmeric<\/a>, <a href=\"http:\/\/ludumdare.com\/compo\/tag\/unity\/\" rel=\"tag\">unity<\/a><\/p>","time":"December 13th, 2013 7:47 am","title":"Sprite Code for Unity and Desktop Photo","title_was_empty":false}