{"author_name":"recursive frog","cat":"LD #22","comments":[],"epoch":1324162440,"likes":0,"metadata":{"p_key":"61268","p_author":"recursive frog","p_authorkey":"504529","p_urlkey":"97033","p_title":"(-o^_^)-o Wishes that things could be just like they used to!","p_cat":"LD #22","p_event":"LD22","p_time":"1324162440","p_likes":"0","p_comments":"0","p_status":"UPD5","us_key":"504529","us_name":"recursive frog","us_username":"recursive frog","event_start":"1323993600","event_key":"8","event_name":"LD22"},"text":"<p>Uh oh! \u00a0It looks like the HugMonster was a little too tight with its squeeze! \u00a0That was fun, it really wants to do that again!<\/p>\n <p><a href=\"http:\/\/www.ludumdare.com\/compo\/2011\/12\/17\/o_-o-wishes-that-things-could-be-just-like-they-used-to\/demo002\/\" rel=\"attachment wp-att-93245\"><img class=\"alignnone size-medium wp-image-93245\" src=\"http:\/\/www.ludumdare.com\/compo\/wp-content\/uploads\/2011\/12\/demo002-300x233.png\" alt=\"\" width=\"300\" height=\"233\" srcset=\"http:\/\/ludumdare.com\/compo\/wp-content\/uploads\/2011\/12\/demo002-300x233.png 300w, http:\/\/ludumdare.com\/compo\/wp-content\/uploads\/2011\/12\/demo002-550x428.png 550w, http:\/\/ludumdare.com\/compo\/wp-content\/uploads\/2011\/12\/demo002.png 650w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n <p>And now you can! \u00a0Just press the space bar when you get a game over and you can restart your level.<\/p>\n <p>&nbsp;<\/p>\n <p>I&#8217;ve automated as much as possible. \u00a0The player and hugmonster don&#8217;t need any special babysitting for resetting their state to whatever it was initialized as. \u00a0The switches are another story, and that&#8217;s because they have individualized behaviours for every level. \u00a0I have the following idiom :<\/p>\n <p>&nbsp;<\/p>\n <pre>using UnityEngine;\n using System.Collections;\n \n public class ResetBehaviour : MonoBehaviour {\n \n public Vector3 resetToPosition;\n public Quaternion resetToRotation;\n public Vector3 resetRigidBodyToVelocity;\n public Vector3 resetAngularVelocity;\n \n \/\/ Use this for initialization\n void Start () {\n RecordStartingVariables();\n }\n \n public void RecordStartingVariables(){\n resetToPosition = transform.position;\n resetToRotation = transform.rotation;\n if(rigidbody != null){\n resetRigidBodyToVelocity = rigidbody.velocity;\n resetAngularVelocity = rigidbody.angularVelocity;\n }\n }\n \n public void ResetGO(){\n Debug.Log(\"Default ResetBehavoiur\");\n transform.position = resetToPosition;\n transform.rotation = resetToRotation;\n if(rigidbody){\n rigidbody.velocity = resetRigidBodyToVelocity;\n rigidbody.angularVelocity = resetAngularVelocity;\n }\n }\n }<\/pre>\n <p>The player, hugmonster, and anything else that requires more than simply transform and velocity resets extends this class and declares new versions of Record \/ Reset.  It works out really nicely for most things, but again, those switches&#8230; because they have individualized behaviors and each level has its own Switch handling delegate, it&#8217;s got to be repeated for every switch delegate.  I guess that&#8217;s better than some alternatives.<\/p>\n <p>But this is exciting!  I&#8217;ve got all the basics up and running.  Multiple levels, restarting on game over, enemy AI, user control, and environment interactions.  There are still some more unique environment tricks I want to pull, but this is a really solid start and sets me up for a lot of level design.  I guess I could use a title and end screen while I&#8217;m at it. <img src=\"http:\/\/ludumdare.com\/compo\/wp-includes\/images\/smilies\/simple-smile.png\" alt=\":)\" class=\"wp-smiley\" style=\"height: 1em; max-height: 1em;\" \/><\/p>","time":"December 17th, 2011 5:54 pm","title":"(-o^_^)-o Wishes that things could be just like they used to!"}