I just put up a tutorial on the wiki here, involving the 2D shooter + level editor project from here. No, this isn't the long-awaited 2D platformer tutorial; it's just something I put together over the last couple of days. It's not about how to create a 2D game, but about working with and extending a Unity project, with some scripting, so I don't think there will be any overlap. At first it was just going to be a brief thing, but somehow it got...longer. I tried not to make many assumptions about the hypothetical reader's abilities, so I guess it's more oriented towards beginners. It could probably use some screenshots. However, I've also attached here an extended version of the project from the above link, with everything from the tutorial up till Part 7, section 2 included (except Part 6, section 1a, 'cause I was too lazy), which might be useful as an illustration if I explained stuff wrong or left something out. Which is likely , so let me know about mistakes, etc. NOTE: a newer version is available here. It's mostly the same as the attached version, but recompiled as a Unity 4.3 project. I'd replace the attachment here but that doesn't work for larger files anymore, so I'm leaving it for posterity or something...maybe people who for some reason are using an earlier Unity version.... --Eric
Wow, this looks like you've invested quite some time into it. I only rushed over it but it looks very good!
Thanks; hopefully someone gets something from it. Forgot to say, I updated the project from the first link (the non-extended version), so if anyone downloaded that previously, it's been changed a little since then and won't quite work with the tutorial. (I don't think Santa says "yo ho ho" unless he's also a pirate with a bottle of rum. ) --Eric
wow eric that's awesome - finally got a chance to look at it and its chock full of cool stuff (that level editor is sweet!) fantastic work very generous of you ; )
OK, it's been bugging me for days that I didn't implement all the scripting suggestions from the last couple pages of the tutorial, so I went ahead and finished it (except for the "lots o' stuff" part). So now the enemy ships won't crash into walls and they do pathfinding, so they can go around walls instead. Updated project folder above...replace the SimpleEnemy prefab on the Manager script with the Enemy prefab if you want to see the more advanced scripts in action. I updated Part 7 of the tutorial to cover some of the new stuff. --Eric
hey! This is great...Ill dig thru this as well! thank you! Looks like there are still lots of people who love the ol 2d! ( doh - Im using iPhone Unity - so the types are all required to be strict...do you you have a web based gameplay version of this? ) cheers, Tj
I put #pragma strict on all the scripts...there were only 2-3 lines that needed to be changed after doing that, but here's the whole lot anyway. --Eric
hey this is awesome...thank you for sharing. Its like Asteroids in a cave! thank you again. cheers, Tj
Hi Eric, I downloaded the code but kept getting the following error on Unity 2.1: Assets/2DShooter Assets/Scripts/FPSCounter.js(7,2): BCE0153: 'UnityEngine.RequireComponent' can be applied on one of these targets only : Class. I had to replace it with @script RequireComponent(GUIText) Also, it's amazing how horrible I am at this game.
Oops, thought I fixed that ages ago. Anyway you can make levels as easy as you want them to be, so make a level without any enemies, then you will be awesome at the game. --Eric
I got that error on my pc, unity 2.51 MissingReferenceException: The variable shootSound of 'BulletControl' doesn't exist anymore. This happened in the game object "Bullet2". You probably need to select the "Bullet2" in the hierarchy and reassign the shootSound variable of the 'BulletControl' script in the inspector.
Well - seems like I'm three years too late for this thread but the tutorial and sample project are both awesome still! I opened the sample project in Unity 3.0, did the automatic project upgrade it prompts you for and got a bunch of compile errors since it seems that they have made an official Unity class named 'EditorGUI' which conflicts with the script in the sample project. In case anyone's stuck on that I just renamed both the script file and all references to it in LevelEditor.js to 'MyEditorGUI' and now it's working great. Thank you Eric!
Anyone got this sample to work with the new Unity3D 3.x ? I am really a newbie here and curious to find out how Unity3D works, compared to Flash and DirectX... I am trying to build some sort of "level loader" with tiles... I have webserver available for assets... just need some sample projects to learn the Unity3D style from.
You need to change all instances of "EditorGUI" to "EditGUI" or something else that's not "EditorGUI", which is an actual Unity class now. In any case I've updated the project. --Eric
Interesting, i thought such things would be automatically corrected if you import an older project into a newer Unity version as well.
aha!, went through all the compiler errors and did as you said. Now I can run the game, but suddently I got a "UnityException: Texture 'wall_corner" is not readable, the texture memory can not be accessed from script.... Dang! I look forward NOT to being a newbie someday.
Did you download from the link (here it is again) rather than the attachment? I should probably just delete that.... Anyway that error means you need to mark the texture read/write enabled in the texture settings, although that's already done in the updated project. --Eric
Amazing this project is still so very relevant. Thanks Eric. This may just be my next little Unity thing to play with. I've been trying my best to concentrate on C4D tutorials for a while but shall be back to some Unity soon. I've got an older project I worked on that was missing a level editor - so, I'm hoping this could be my stepping stone to creating one.
Hey do you have the version of the demo working with Unity3 I been trying to get it work but no look so far. Cheers
The link for the Unity 2.6 version in the first post should work fine. It will bring up a message with some scripts that need to be altered, so just click "fix now" and it seems to work with no issues. --Eric
Hey Eric, this rocks! I've been working with your tutorial and playing with your example project for the last few days and have switched out the graphics with my own to create a pretty neat looking little shooter I was about to upload my project on Kongregate and release it to the masses, then realised I hadn't actually seen any licensing terms for using your examples and code. If the work I have created takes off on Kongregate am I allowed to sell my work on other platforms? Am I even allowed to upload it to Kongregate? Have you released your work under any specific license? I'm hoping it's public domain so that I can sleep at night without worrying about being sued!!
Can someone help me out? Everytime I do a search this project keeps coming up. Only problem is I can't get it to work. I'm sure I'm doing something wrong. But how do I import this in Unity'? I create a new project, copy the files in windows explorer and reopen the project. This way Unity corrects it for version 3, but all the script references are gone and all I see is a pink plane. If I try to copy it in Unity, all I can copy is the asset folder, but not the library. I'm sure it's an easy mistake, but if someone can help me out that would be great.
If you look at the scripts in the IDE you will see that their public variables are listed under the code window, now if you look at the missing links the game objects contain you will see they contain variable details, all you need to do is match them up and re-link the script, it's time consuming and make sure you save often but this approach worked for me. Starting from this tutorial I eventually made 'Cure Em Up!' http://cancerwarsgame.org/
Thanks for the tips. Not sure what happened, but when I tried again it worked directly. So now I just got to figure it all out. Liked your game btw, shows how to take a simple concept and expand it with your own ideas...