Search Unity

Can I create Worms or Scorched Earth with Unity?

Discussion in 'Editor & General Support' started by sofakng, Feb 26, 2008.

  1. sofakng

    sofakng

    Joined:
    Feb 26, 2008
    Posts:
    38
    I'm looking to create a Worms or Scorched Earth type of game and am wondering if this can be done in Unity 2.0 (Indie).

    Just in case anybody has never heard of Worms (???), it's a simple game where there is a 2D terrain that can be destroyed using rockets, etc. The game is also multiplayer (which is a key element).

    So basically I'm wondering this:

    1) Is it possible to make some sort of destructible 2D terrain?
    2) How difficult would it be to synchronize the terrain and the projectiles over a network?

    I realize that destructible terrain is probably not possible (*sigh*), but can I even come close to it or fake it somehow?

    It looks like Unity 2.0 Professional supports render-to-texture effects but $1500 is definitely far and beyond my price range :(
     
  2. Jonathan Czeck

    Jonathan Czeck

    Joined:
    Mar 17, 2005
    Posts:
    1,713
    It is. What I would recommend for the best graphical effect, and is also probably the easiest, is to just use the built-in terrain system coupled with what the 2D Tutorial is doing. Just craft your terrain so its main features are in plane and clamp your characters and projectiles to that plane.

    Relevant links:
    http://unity3d.com/support/resources/tutorials/2d-gameplay-tutorial
    http://unity3d.com/support/documentation/Manual/Terrains.html

    The cool thing about the terrain is that it's very easy to alter at runtime, since it's a heightmap:
    http://unity3d.com/support/documentation/ScriptReference/TerrainData.SetHeights.html

    No more challenging than a similar multiplayer game. (As you might know, internet multiplayer is just inherently one of the harder things you can do with any game.) Just be smart about the terrain part, for example don't send the actual data to deform, just send a command to deform the terrain at a certain location at a certain amount, possibly with a certain random seed.

    Cheers,
    -Jon
     
  3. sofakng

    sofakng

    Joined:
    Feb 26, 2008
    Posts:
    38
    Thank you very much for the reply!

    Using the terrain heightmap, would it be possible to create overhangs? (eg. parts of the terrain that is above other parts of the terrain?) ...or must each X coordinate only have 1 corresponding Y height position?
     
  4. Jonathan Czeck

    Jonathan Czeck

    Joined:
    Mar 17, 2005
    Posts:
    1,713
    Overhangs aren't possible with a heightmap, yeah. Hrm, I guess that may not be that cool for a Worms type game. Maybe you can just make everything else so great that the player forgets there aren't overhangs. :) There is a mesh interface where you can create and modify meshes at runtime. It'd be a lot harder to go this route, I think, but it'd allow overhangs.

    http://unity3d.com/support/documentation/ScriptReference/Mesh.html

    Cheers,
    -Jon
     
  5. drJones

    drJones

    Joined:
    Oct 19, 2005
    Posts:
    1,351
    you'll have to model overhangs separately, its just the way heightmap based terrains work.

    also FYI Sector3 has a unity based scorched earth type game already:

    http://forum.unity3d.com/viewtopic.php?t=9695

    EDIT: beat me to it ; )

    and BTW welcome sofakng : )
     
  6. sofakng

    sofakng

    Joined:
    Feb 26, 2008
    Posts:
    38
    Actually, wouldn't I just be able to use the built-in state synchronization for everything? Could I do that for the projectiles to make sure they follow the same flight paths, etc?
     
  7. careyagimon

    careyagimon

    Joined:
    Dec 20, 2007
    Posts:
    209
    You could use a 2D texture and work out a some sort of raytracing system using getPixel. Weapon damage to the terrain would then be applied with setPixel. You would have to figure out your own physics system since there wouldn't be any Unity defined colliders and such.

    Hmm, this might be my next project. :)
     
  8. sofakng

    sofakng

    Joined:
    Feb 26, 2008
    Posts:
    38
    Thanks for the reply...

    It sounds like Unity might not be the best choice for me since it sounds like I'll need to write my own physics and terrain engine.

    I'm suprised and just how hard it is to create a simple game like Worms :(
     
  9. forestjohnson

    forestjohnson

    Joined:
    Oct 1, 2005
    Posts:
    1,370
    Unity is a 3D engine that is designed for all types of polygon pushing applications. It can do 2D games and gameplay fairly easily, but the type of pixel based dynamics that worms uses is just not something that Unity is designed for.

    That said, people have done similar things in Unity (Pixel based collision, 2D games) and as far as I know creating a 2D tile system and pixel based collider in Unity would be easier than creating an entire game engine. (Though there may be an alternative already out there that does this pixel stuff well)

    And from what I've seen of worms, its not a very simple game. (Compared so say, marble blast )
     
  10. hai_ok

    hai_ok

    Joined:
    Jun 20, 2007
    Posts:
    193
    tell that to the guys who wrote worms.

    seriously. I own a LOT of engines. They haven't all been the best tool for my needs, but game development engines only come in three flavors: "Bare Metal", "Pipeline Driven", and "Just Add a Splash Screen".

    "Bare Metal" engines are source code based and usually use a custom set of formats with their own proprietary converters. You need to compile everything, every time you change it, and sometimes even redelpoy it just to test it in-house. You're lucky if you have a gui level designer and a graphics format that you can actually read with photoshop. You can do anything with them, but they take nothing for granted, so you will spend most of your time inventing wheels.

    "Pipeline Driven" engines are well suited for the formats they handle so its easy to produce content for them. They are the hub around which the stuff goes in and the games come out. They assume that you live on earth, you will be using industry standards, and the standard tools that create them, and you can focus on play mechanics and fun, instead of basic functionality. You can usually do just about anything with them, but some knowledge is usually required to use them to craft your ideal game.

    "Just Add a Splash Screen" engines, are almost exactly that. Sure, you can usually create custom sprites and even some artwork, but these tools are designed to make a very specific type of game and are only well suited if that's almost exactly what you plan to do with it. When you want it to do something outside of it's intended functionality, you are almost always out of luck. The play mechanics have already been designed and you are simply a content developer.

    Sure there are some that have elements of some or all three of these. But it sounds like you are looking for something in the lower pipeline/upper JAaSplash category. I have never seen a "Worms" genre development engine.

    Unity falls somewhere near the top of the Pipeline variety. A considerable effort has been made to offer us the flexibility and functionality to craft our own play mechanics, without making us do it all from scratch. I know its discouraging to learn that you have to craft the parts that make your game so great, but knowing that you can do it is more than worth the work.

    You can change things that don't act the way you expected. That is the exciting part. It's in your hands and not up to the whim or even spare time of someone who may be developing your livelihood in his spare time. I had to give up my favorite programming IDE because it got sold to a guy who didn't like his users or have time to develop the product.

    If you want my advice, you should put a few miles on Unity. Take it out for a spin and see how it handles. I've been doing this for a long time and I am using Unity for a lot of very good reasons. Of the game dev tools I have seen/owned, Unity is the best.

    Unity may not seem well suited for your game ideas, and it may mean that you have to use a different method to reach your goals, but I'd be surprised if you couldn't make something you were very happy with. (You may have to substitute pixels for particles or even polygons, but you'll have a great time figuring out how to get it to do what you want).

    But you probably shouldn't ask me. :wink:

    It works for me, but your mileage may vary.
     
  11. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    I did destructible 2D here, which also has the project available. It's actually not that hard, though the code there could be a little better. You don't need your own physics system per se (I used Unity's physics for that); you just need a way to detect collisions, which I did with raycasting.

    But yeah, Unity's not a 2D engine and won't quite behave like one. The original Worms was done on the Amiga using BlitzBasic, which is still around and quite good from what I hear. (Although the original original version was done with AMOS.)

    --Eric
     
  12. andeeeee

    andeeeee

    Joined:
    Jul 19, 2005
    Posts:
    8,768
    If you are talking about the original Worms with the side-on view (ie, not a 3D landscape) then you could use a simple 2D bitmap structure or a texture to represent the terrain and use "explosions" to remove chunks of it. A bit of image processing is necessary to convert the terrain image into a mesh, though. A book with a chapter on bitmap image processing will likely mention "chain coding" or other techniques for tracing the edge of an image.

    Once you have updated the mesh after an explosion, you can just call Mesh.RecalculateBounds to make the physics engine recognise the new shape. No need to home-brew your own physics.

    (Quite a bit of work, I know, but Worms is an unusual type of game, really.)
     
  13. hai_ok

    hai_ok

    Joined:
    Jun 20, 2007
    Posts:
    193
    Yoggy, andeeee Eric5h5 are the guys to listen to. (anyone but me)

    I used to use AMOS! Man the AMIGA is the best!!!

    To add to what Eric5h5 said, I used to use another engine (3D RAD, which became 3Impact) and people said you couldn't write a basketball game with it. I knew they were wrong. I didn't even know most of the rules of basketball. I don't like basketball and I didn't know how to work out the real world physics, but I knew how to make it look like I loved basketball and I knew all about physics.

    I faked it.

    After all, it's not what you know, it's what you can fake. I mean in a game, there is no difference. What your users see, they will believe. It's fuzzier than right or wrong. It's all methodology unless your doing forensic accident reconstruction in a court room.
     
  14. andeeeee

    andeeeee

    Joined:
    Jul 19, 2005
    Posts:
    8,768
    Now I think of it, can anyone confirm whether Unity's font system traces bitmaps or works from the original TrueType data?

    I'm just thinking that it might be possible to put the terrain data into a "font" and use a TextMesh to turn it into something a character could walk on.

    Grasping at straws perhaps!
     
  15. sofakng

    sofakng

    Joined:
    Feb 26, 2008
    Posts:
    38
    Wow... I really screwed up big time.

    I didn't realize that Unity was only for Mac OS. I only have Windows machines so it looks like I won't be able to use this.

    Does anybody have any good alternatives for Windows? (I already own Torque [TGB and TGE] and BlitzMax but don't really like either of them...)
     
  16. forestjohnson

    forestjohnson

    Joined:
    Oct 1, 2005
    Posts:
    1,370
    It converts the font to pixels and then stretches those pixels onto polygons. Its not insane to use fonts for sprite things, Neil did it for a unity version of Yoink! which worked fine.


    One alternative a lot of people on this forum have chosen and are very happy with is to just buy a mac. Why aren't you happy with torque game builder and blitzmax? I've heard good things about both as far as 2D engines go, though I don't know how they are structured. Do they give you any access to read or write pixels? Because if they do, Unity won't be any better than them for a worms game.
     
  17. podperson

    podperson

    Joined:
    Jun 6, 2006
    Posts:
    1,371
    Blitz3D is pretty nice. (Easier to get started with than BlitzMax.)

    Buying a Mac is the A option though ;-)
     
  18. stimarco

    stimarco

    Joined:
    Oct 17, 2007
    Posts:
    721
    If time isn't an issue, you could wait for the Windows version of Unity! :)

    That said, BlitzMax could easily do a 2D Worms-type game without much trouble, (though it could really use a better IDE). There are a few third-party modules you can get for it, which would give you all the sprite and basic physics you need for such a game, but I freely admit that I haven't even touched BlitzMax since I first clapped eyes on Unity.

    Incidentally, Unity *can* do traditional sprite-based 2D games. It requires some scripting, but there's a tutorial doing the rounds which shows how it can be done, here.

    (The 2D Gameplay Tutorial we have on our website was designed to leverage the existing 3D pipelines most Unity developers will have, so it uses 3D assets with locked-off camera and physics.)