-
Dorkshop 2013: Dynamic Level Management with Google Drive and Unity 3D!
Resources & Requirements:
- Internet connection
- a Google drive account
- Unity 4: I will be using this game creation tool for the dorkshop, but the backend will work with other web player such as FLASH. Yes, FLASH rules.
- jQuery javascript Backend: The code is partially based on Mike Mikay’s google-spreadsheet-javascript example. Only needed for the Unity 3D Web Player.
- in-shop sample code: a Unity package.
- notepad
- some web space.
Overview:
something, something level design
mini game jam [live demo][Still compiling notes from the Dorkshop]
[ Part 1 ] Create and publish a Google spreadsheet
1. All we need is a Google spreadsheet, adding a form is just more fun and help us collecting data more easily.
2. Once the spreadsheet is up, publish it to the web.
3. The default output format is Web Page, change it to CSV (Comma-separated values)
4. Copy the link to the CSV file and save it for later.[ Part 2 ] Unity 3D platformer in a flash:
I. Scene setup:
1. Go to Main Camera’s Inspector window. Change Projection to Orthographic, and Size to 4.0. (Main Camera and other newly created GameObjects can be found in the Hierarchy window.)
2. Create a Cube from Menu/GameObject/Create Other/, and rename it to “Player” in the Hierarchy window.
3. In the Inspector window, change Player’s Position to (-2, 2, 0) and Scale to (1, 1, 1).
4. In the same window, find Box Collider component and remove it with Remove Component option.
5. Create another Cube and named it “Platform”. In the Inspector window, change its Position to (0, -4, 0) and Scale to (8, 8, 3).II. Import package files:
1. In the Project window, right click on the Assets folder and go to Import Package/Character Control.
2. A pop-up window will show up, import PlatformInputController.js and CharacterMotor.js two files only.
3. Go back to Player’s Inspector window. At the bottom of the window, click [Add Component]. In the drop-down menu, go to Character and add PlatformInputController.js and CharacterMotor.js to Player.
4. Now click the play button on the top. On the keyboard, press A to move left, D to move right, and space bar to jump. It should work like a magic!You might not notice this due to the orthographic view, but the Player is still moving 3 dimensionally and will eventually roam off the platform on the Z axis. To fix that, a few lines of code needed to be added to the CharacterMotor.js to eliminate the motion on Z axis.
5. Open CharacterMorot.js in MonoDevelop or other editor you prefer. Do a search (Command + f ) on “return velocity;” and replace both line to:
return new Vector3(velocity.x, velocity.y, 0.0f);
[ Part 3 ] Data parsing
1. Import the Unity package file downloaded earlier. (Ok to all overwrites)
2. Create an empty GameObject and name it “lvlManager”
3. In the scripts folder under your Asset, add javaListener.js and javaParser.cs two scripts to the lvlManager.
4. Keep lvlManager opened in the Inspector window, go to the prefabs folder under your Asset, assign Platform and Marquee to javaParser’s Platform prefab and Text prefab.
5. The set-up we just did was designed to work with web player, and you won’t be able to test it by the Unity itself.
6. Check the build type: go to file/Build Setting. Make sure the current build is on the Web Player. If not, select the Web Player and click on the build button.
7. Drag the filename.unity3d file from your build folder to our jQuery Javascript backend folder (download earlier and unzipped). Rename your file to dorkshop.unity3d for the purpose of testing (and awesome too.)[ Part 4 ] Javascript
Find the following code block in the dorkshopEmbedded.html and replace the highlighted values with yours:Replace Value 1 = link the your Google CSV file
Replace Value 2 = The name of the GameObject in Hierarchy window that has the javaListener script attached.function myFunction() { localStorage.clear(); var sample_url = "Replace Value 1"; var url_parameter = document.location.search.split(/\?url=/)[1] var url = url_parameter || sample_url; var googleSpreadsheet = new GoogleSpreadsheet(); googleSpreadsheet.url(url); googleSpreadsheet.save(); googleSpreadsheet.load(function(result) {u.getUnity().SendMessage("Replace Value 2", "GiveID", cdata); url = result.data; $('#results').html(JSON.stringify(result.data).replace(/,/g,",\n"));}); }
[ Part 5 ] test it All together
Now save the html file and open it in a browser. After the unity web player is fully loaded, click on the “Update level” button. (ノ◕ヮ◕)ノ*:・゚✧*:・゚✧ Magic moment! If not, make sure all the steps are done correctly, check for typo and casing. Good luck! ( ´ ▽ ` )ノ[ Update ] 4/30/2014 The new Google drive, the option to publish .csv is no longer visible, however, the function is still there. Go to the share screen of your spreadsheet and copy the key and replace in the following link and you are all set!
CSV file : https://docs.google.com/spreadsheets/d//export?format=csv
15 Mar 2013 / admin / 0
Categories: games
Gozilla Paper Holder ゴジラ ペーパーホルダー Fight-back Hoodie & Bullet-proof baby car seat
Pages
Categories
Archives
- June 2016
- April 2016
- March 2016
- February 2016
- July 2015
- June 2015
- May 2015
- April 2015
- March 2015
- February 2015
- January 2015
- December 2014
- June 2014
- May 2014
- February 2014
- December 2013
- November 2013
- October 2013
- September 2013
- August 2013
- June 2013
- May 2013
- April 2013
- March 2013
- February 2013
- January 2013
- December 2012
- November 2012
- October 2012
- May 2012
- April 2012
- March 2012
- December 2011
- August 2011
- February 2011
- December 2010
- October 2010
- July 2010
- June 2010
- April 2010
- March 2010
- February 2010
- December 2009
- November 2009
- October 2009
- September 2009
- August 2009
- July 2009
- April 2009
- March 2009
- November 2008
- October 2008
- August 2008
- June 2008
- May 2008
- April 2008
- December 2007
- October 2007
- August 2007
- July 2007
- May 2007
- April 2007
- March 2007
- February 2007
- November 2006
- October 2006
- September 2006
- March 2006
- February 2004
- August 2003
- September 2001
Comments are currently closed.