Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Asteroids clone

Discussion in 'Works In Progress - Archive' started by TwiiK, Nov 24, 2014.

  1. TwiiK

    TwiiK

    Joined:
    Oct 23, 2007
    Posts:
    1,729

    http://twiik.net/unity/asteroids

    Over the next couple of weeks, possibly months, I'm going to clone the original Asteroids, just for fun. What I have at the moment is just silly, but I uploaded it just because I found it oddly satisfying to watch my ship plow its way through the polygons and maybe you do too. It has a very physical feel to it, like you're digging through gravel or something. :p I often end up finding weird game ideas by just messing about like this. :p

    I'll base my clone on various information, but mainly what I find here:
    http://www.classicgaming.cc/classics/asteroids/index.php

    I thought it was nice how they've written about how the game should work and even supplied you with the sound effects etc. I've never actually played the original so I'll make it as I think it should be.

    I have a plan to add a fun little easter egg in the end as well. :)

    The entire project will be made available when I'm done and you can choose to draw it using Eric5h5's Vectrosity (if you have it) or normal line renderers if you don't. I bought Vectrosity a long time ago, but I've never used it so I thought I would test it out on a fun little project.
     
  2. TwiiK

    TwiiK

    Joined:
    Oct 23, 2007
    Posts:
    1,729

    http://twiik.net/unity/asteroids

    Version 0.2.0 is up:
    • Added sound effects to Asteroids blowing up, shooting and thrusting.
    • You can now blow up Asteroids into smaller chunks.
    • Added a score counter which uses line renderers instead of font rendering to keep it consistent. And it was fun to make. :p
    Anyone know why Input.GetAxisRaw doesn't immediately return 0 when I let go of the key? I'm using it for thrusting and I'm playing the thrust audio clip whenever Input.GetAxisRaw > 0, but the thrust sound lags behind some times. It seems random.
     
  3. TwiiK

    TwiiK

    Joined:
    Oct 23, 2007
    Posts:
    1,729

    http://twiik.net/unity/asteroids

    Version 0.3.0 is up:
    • Started using Vectrosity instead of Line renderers. It looks so much nicer
    • Made the game black & white
    • Added lives
    • Added the hyperspace button (shift) which teleports you to a random spot on the screen. Didn't know of that one until I saw it on Youtube. :p
    • The game is playable now as long as you don't die. :p A new level will start each time you clear out all the asteroids
    Known bugs
    • If you lose all your lives the game restarts, but Vectrosity crashes catastrophically when that happens
    • There's some weird flickering as if it's trying to render using both Vectrosity and Line renderers at the same time
    • When you hyperspace the ship graphics stay behind when they should disappear
    As for Vectrosity it's very fiddly to work with unless I'm missing something. I was not able to get the normal screenspace drawing to work with my existing game so I'm using Draw3D, but I'm having to clean up each line manually when I destroy an asteroid or a projectile disappears which is annoying. Extra code I didn't need when if using Line renderers.

    Also this happens when I call Application.LoadLevel(0) to restart the game when you lose all your lives.

    Code (csharp):
    1. MissingReferenceException: The object of type 'Camera' has been destroyed but you are still trying to access it.
    2. Your script should either check if it is null or you should not destroy the object.
    3. UnityEngine.Camera.WorldToScreenPoint (Vector3 position) (at C:/BuildAgent/work/d63dfc6385190b60/artifacts/EditorGenerated/UnityEngineCamera.cs:381)
    4. Vectrosity.VectorLine.Draw3D ()
    5. DrawObject.Update () (at Assets/Scripts/DrawObject.cs:52)
    I've never actually used Application.LoadLevel(0) before, but I thought it was supposed to just reload the scene as if you've just hit the play button in the editor? Without Vectrosity it seems to work perfectly, but with Vectrosity it blows up completely. I haven't actually debugged that one very much yet, just posting it here in case anyone has any ideas.
     
  4. TwiiK

    TwiiK

    Joined:
    Oct 23, 2007
    Posts:
    1,729
    Version 0.3.1 is up:
    • Removed Vectrosity from the project. It required to many code changes to work properly.
    • Made it so the line renderers draw the lines once normally and once in reverse order. This covers up a lot of the twisting and makes the lines look much better than they did before. Not as good as Vectrosity, but close.
    • Since Vectrosity caused all the known bugs they are all fixed now.
    As for Vectrosity it's clear that it offers many possibilities not available using line renderers, but it required me to make too many changes to my code to work properly. I was hoping that I could just drop it in like a replacement for Line Renderers, but you have to manually clear up Vectrosity lines, delete the canvas after a scene load, reset the Camera after a scene load etc. Also I'm using Line Renderer visibility to tell when objects have exited the screen. That would have to be handled differently.

    I will proabably test it out in a separate project I build from the ground up for Vectrosity.
     
  5. TwiiK

    TwiiK

    Joined:
    Oct 23, 2007
    Posts:
    1,729
    Version 0.4.0 is up:
    • Added a menu with a few options. Many more options to come.
    • Fixed the transitioning from left to right and top to bottom. Asteroids, bullets and the player should now smoothly exit and enter the screen from all angles.
    • Added the default 4 bullets max mode from the original. I've chosen to keep autofire though. Having to spam the spacebar to fire is not very user friendly. May make it a choice later to preserve the original click to fire design.
    • Added simple particle effects.
    I have mostly been fiddling about with the new GUI for this version. It seems pretty easy to work with. I don't understand why you can't have dynamic ints for sliders though. I refused to read the documenation or look at tutorials at first to see how intuitive it was, but when I created a callback function for my slider which accepted an int it didn't show up as a dynamic parameter. Only when I watched a tutorial and realized you had to use a float did it work. No big deal, but seems silly not to accept both. Especially when my slider is set to use whole numbers to begin with.
     
  6. LanceUppercut

    LanceUppercut

    Joined:
    Dec 10, 2012
    Posts:
    11
    Man this looks really cool, at work at the moment but I am gonna fire up the web player tonight when I get home. There is just something special about the simplicity of the old arcade games that I think a lot of modern day games seem to miss.
     
  7. TwiiK

    TwiiK

    Joined:
    Oct 23, 2007
    Posts:
    1,729
    Thanks. I think Geometry Wars and Grid Wars are excellent successors to games like Asteroids. I'm not really a fan of the Asteroids gameplay myself, but it's a fun game to make. Especially when I don't have that much time to spare. It's fun to see fast progress rather than spending months on a single 3d model or something similar. And I have some ideas for some extra options that might spruce it up a bit.
     
  8. TwiiK

    TwiiK

    Joined:
    Oct 23, 2007
    Posts:
    1,729

    http://twiik.net/unity/asteroids

    Version 0.5.0 is up:
    • Added an option to turn on asteroid collision. It's not perfect yet, but it's fun.
    • Added UFO's. Currently one UFO spawns on the left side of the screen every 10 seconds and travels across towards the right randomly firing in all directions.
    • Asteroids now have random shapes.
    • Added the "Jaws" background music.
    Known bugs
    • Some options seem to "stick" after the game restarts if you lose all your lives so you may not get the correct bullet cap and asteroid collision setting it seems.
    • I think the UFO's reset your bullet cap if you have it enabled.
    Halfway there. I will try and complete it and make it available for download by Christmas.
     
  9. TwiiK

    TwiiK

    Joined:
    Oct 23, 2007
    Posts:
    1,729
    Version 0.6.0 is up:
    • Added a new game option. You can now choose to play with a rechargeable shield instead of the normal 3 lives. Enemy UFO's will also have shields with this option selected, but their shields do not recharge.
    • Fixed asteroid collisions when that option is enabled.
    • Added the small UFO which actually aims at you.
    • Given the UFO's some form of AI. The small one is smarter than the big one.
    • Fixed the known bugs.
     
  10. TwiiK

    TwiiK

    Joined:
    Oct 23, 2007
    Posts:
    1,729

    http://twiik.net/unity/asteroids

    Version 0.7.0 is up:
    • Added game presets to the menu. You can now choose between "classic", "next-gen" or "custom". Next-gen is lackluster at the moment, but I have some ideas. :p
    • Added the pointy flame to the end of your ship.
    • Tweaked the way the shield mode works. You now have 20 shield and lose 5 when getting hit. You regain 1 shield every 5 seconds if you don't get hit.
    • Added stars in the background.
    On the roadmap are silly effects for the next-gen mode, maybe even separate sound effects. Server side highscores and a lot of tweaks.

    I will make a tutorial for server side highscores I think. May even make a tutorial about permanent particles like for my stars because I thought that was pretty cool as well and enables a lot of fun effects not possible through Shuriken without scripting.
     
  11. TwiiK

    TwiiK

    Joined:
    Oct 23, 2007
    Posts:
    1,729
    Version 0.8.0 is up:
    • Server side high scores are in the game. Get your name on the board. :p
    Now mostly tweaks, polish and some small bug fixes remain.

    Edit: Currently, you have to play from http://twiik.net and not http://www.twiik.net for the high scores to work. Without www is the domain I've used in the game and Unity treats the other as a separate domain and stops it because of the crossdomain policy. I will fix that soon, but I'm not too server savvy and my colleagues don't want to help me with hobby projects. :p
     
  12. TwiiK

    TwiiK

    Joined:
    Oct 23, 2007
    Posts:
    1,729
    Version 0.8.1 is up:
    • You now have to enter at least 1 letter to be able to submit your score and you can only click the button once. I took the liberty of giving new names to those who managed to submit blank names.
    • Removed the next-gen mode. I've decided to cut features to get this finished faster and will instead include them in a different project.
    • Fixed a bug where the shield and/or flame of your ship would be visible when you died or teleported.
    As for the next-gen mode I had created some really cool distortion and particle effects for explosions and the hyperspace to make it look more like Geometry Wars, but I decided that it took too much time and this is not a project I want to spend that much more time on. I will include them in some other project.
     
  13. TwiiK

    TwiiK

    Joined:
    Oct 23, 2007
    Posts:
    1,729
    Version 0.9.0 is up:
    • Changed "Volume" to "Game volume".
    • Changed "Preset" to "Game mode".
    • Added descriptions to what the different game modes are.
    • Added "Game over" title text and a slight delay before the score prompt appears.
    • Added a small delay before the next wave starts.
    • Added extra lives at score multiples of 10000.
    • Changed it so asteroids don't spawn on top of the player.
    • Added a few seconds of invulnerability after death.
    • Allow UFO's to spawn on the right side of the screen and fly left.
    • Spawn less UFO's.
    • Tweaked the way UFO's reorient themselves after colliding in shield mode.
    • Made it so that you can only submit your score if you play the Classic game mode.
    • Fixed a bug where asteroids would rotate in classic mode.
    • The music beat now stops when transitioning to a new wave.
    This is the last content update for the game. The only remaining todos I have left are related to some polish here and there. Then I will clean up the project and code and upload the entire project folder for those who want to take a look. I'll call that version 1.0.0 and it will probably be the last version.
     
  14. theANMATOR2b

    theANMATOR2b

    Joined:
    Jul 12, 2014
    Posts:
    7,790
    I love asteroids! Thanks for creating this. And any/all tutorials you can provide is great.

    Did the original asteroids have the ship break apart when you were destroyed? Those little alien ships added a some difficulty to the game. Great work.
     
  15. TwiiK

    TwiiK

    Joined:
    Oct 23, 2007
    Posts:
    1,729
    I honestly don't know. I've never played the original in any shape or form. :p I've found some videos on youtube where people play it on original arcade cabinets and I sort of wanted to recreate everything with the vector glow, curved screen image effect and everything, but I quickly grew tired of the project and now it's mainly just a test to see if I can actually complete some of my Unity projects. :p

    Version 1.0.0 is not that far off, and I will release the project with it, but I've been sick for what feels like the majority of 2015 (or at least a week) so it's a bit delayed. :)
     
  16. orb

    orb

    Joined:
    Nov 24, 2010
    Posts:
    3,037
    I played the original console version (so really the second version, I guess) until the score wrapped around. The ship didn't do anything but disappear when you lost it :)

    This would make an excellent project to go with a tutorial.
     
  17. TheVorbicle

    TheVorbicle

    Joined:
    Jan 8, 2015
    Posts:
    12
    I used to play the original arcade version at the local pinball place.
    I loved this game. Your version is very close to the original.(If my memory serves me right)
    Great job!

    I think the ship was just three lines that spread apart in different directions and disappeared quickly when destroyed.
     
  18. MD_Reptile

    MD_Reptile

    Joined:
    Jan 19, 2012
    Posts:
    2,664
    I made an asteroids style game, was the first game I ever completed and released actually! I like the way you stuck with the original art style mostly, and wow your's sure handles a bunch of asteroids well if that screenshot wasn't crawling FPS lol.

    Anyway good work, even a clone can be a labor of love, I hope to see it turn into something unique and fun!
     
  19. TwiiK

    TwiiK

    Joined:
    Oct 23, 2007
    Posts:
    1,729
    Version 1.0.0 is up and it will probably be the final version. I can't remember if I actually did any real changes to the game in this one. I added a shield hit sound effect and I fixed some bugs. The rest of the time was spent cleaning up the project a bit.

    You can play the game and download the full project from here:
    http://twiik.net/unity/asteroids

    The project folder is clean, but the code is messy, especially the game (menu/audio/score) manager. I've tried commenting the code a bit more than I usually do. I found a few bugs when I was trying to write what a piece of code actually did and then realized it didn't do that. :p