Search Unity

2D Sprites in a 3d Environment

Discussion in 'Editor & General Support' started by Savage_Games, Mar 24, 2013.

  1. Savage_Games

    Savage_Games

    Joined:
    Dec 17, 2012
    Posts:
    4
    Hello all,
    My team is attempting a beat-em-up style game a la River City Ransom, Castle Crashers, etc. We will be using 2D sprites in a 3D environment, and need the sprites to be able to not only move forward and backward, but also towards and away from the camera. I've searched and searched not only on this site, but also googled the hell out of this idea and need some help. I've read articles on billboarding, using sprite manager, and locking cameras and all that, but I'm still lost. I'm brand new to Unity, and have done a few tutorials, though I must admit I haven't found a tutorial that really covers what we're trying to accomplish. Most of the tuts I find are straight 2D movement i.e. forward and backward with no Z depth. Does anyone know of a good tutorial or at the least some information on how to accomplish this? Any ideas/help would be much appreciated. Also, please don't tell me to search the site as I have tried, and couldn't find what I was looking for. If you do know of something on the site, please link it. Thanks in advance. :D

    -Savage
     
  2. renman3000

    renman3000

    Joined:
    Nov 7, 2011
    Posts:
    6,481
    2D movement is the same as 3D movement, just with one axis missing. So, if you can find 2D movement, just add an axis.

    Left button, move left on x axis. right button, move right on x axis. up, down etc. If you need z movement as well, have a "away" button, and a "come closer button".

    One thing, also, note that cameras have the option of being, Orthographic or Perspective. Orthographic is generally good for 2D as it removes the depth of field. An object at 30 z, will appear the same as at 0 z.
     
  3. Savage_Games

    Savage_Games

    Joined:
    Dec 17, 2012
    Posts:
    4
    Yeah, I figured it would involve that, though I am really just looking for a tutorial using a 3D background with 2D sprites, I wasn't that clear in my post. I just need something to give me an idea of where to start. We're still in concept, and there's no deadline, so I'm just looking for other projects that have similar styles so I can get an idea of what I'm up against. My first post was centered around the sprite movement, but I'm really looking for anything relating to a 2D sprite in 3D environment kind of game.
     
  4. renman3000

    renman3000

    Joined:
    Nov 7, 2011
    Posts:
    6,481
    I do not get what you mean. Are you used to building in a 2D engine? If, the fact the building enviroment is 3D and the game is 2D, don't worry about it. It takes some getting used to, but not much. It has some nice advantages too. I did build in a 2D engine before, but now, prefer the 3D, despite making 2D games.

    As far as 2D tutorials for Unity, I can't think of any, but again, I don't really see much difference. Do you have specific areas of concern?
     
    Last edited: Mar 25, 2013
  5. Alf203

    Alf203

    Joined:
    Dec 7, 2012
    Posts:
    461
    If you're new to game development I would suggest starting with a simpler project, something you can easily get your head around. Then, with more experience you will know how it can be done without needing to find a tutorial that tells you how.

    If you want a good inspiration for games in this style, look at (Zombieville 2 done in Unity) although they are using a sprite/plane for each body part, but the idea is the same.
     
  6. playemgames

    playemgames

    Joined:
    Apr 30, 2009
    Posts:
    425
    I've been working on a game like this for a while now, my suggestion is to plan ahead before you start making anything. Figure out character sprite sizes and a pixel to world unit ratio you will use. Your characters will be 2D planes so you will have to figure out the widths for the colliders as well. For 2D animation you can use the SpriteManager on the wiki if you want to get your hands dirty in some code and learn how creating sprites works, or you can use one of the many packages on the asset store, like NGUI, 2DToolKit, Orthello, Smooth Moves, ex2D, Rage Tools, etc, etc, etc. There are too many tools to name but those are a few, some of them have free trials but it all depends on what kind of animation and style you'll use and which tool suits all your needs best. Any kind of animation, whether it be 2D or 3D takes a long time to do, so if you are doing forward and backward walking animations for each character along with left and right animations, be prepared for a lot of animation work.

    If you want to have your character move in 3D, then make sure you use a Perspective Camera since it will make things a lot easier in terms of laying things out. Orthographic is fine for 2D only but not really good to use for 3D movement. You can create a script to lock the rotations of the sprite as well so you don't have it turning, you can flip the sprites as well using scale. Depending on the type of 2D animations you create, will depend on the character controller you use. You may have to come up with something custom depending on how critical it is to have colliders that change size according to the characters. I had to come up with something to match the tools I was using, and ended up creating my own rigidbody character controller, but you can see if the 2.5D Character Controller on the Unity resources or in the wiki and forums here is good enough for your uses. Also there is a good Camera Follow script you can adjust to set up your camera to follow your characters in a fixed position. If you want shadows on your sprites you can see about using a Tree Leaves shader instead of a particle shader so it can cast and receive shadows.

    When you set up your levels, stick to set visual angles so the characters don't seem out of place in the environment. I used 30 and 150 degree angles for most of the turns in the level so it wouldn't seem so awkward for the characters to navigate around.

    You may have to get creative on AI handling in terms of how you control your characters. If you are using a pathfinding set up it may do rotations and other maneuvers you may want to refine the control since your characters are in 2D. I've been mixing and matching my own controls with some of the Unity pathfinding that I have with Pro, but before that I was using an A* implementation that worked pretty good, it all depends on how much control you need over the characters movements.

    Finally if it is a beat-em up, figure out your state system, take your time planning out all the different states your characters will have, and how that will effect them and their movements and animations. This can take a long time to code depending on how complex your game is. I have 24 different states for my characters, so often times I have to check for multiple situations the character might be in and cross check all the states. It can get very tricky depending on what you are planning, so better to keep it simple from the beginning and build on it as you go. Simple states can be walking, jumping, attacking, hit, rising up, and dead. You can set this up in an enum and check to see what state the character is currently in and modify the behavior according to that.

    Hope this helps give you a head start, feel free to PM me or ask me here with any more questions. Good luck with your game :)
     
  7. Savage_Games

    Savage_Games

    Joined:
    Dec 17, 2012
    Posts:
    4
    Thanks for all the responses guys, really a great help. This community is pretty damn sweet.

    Just for a clarification, I am a 3D guy, I have an animator who will be hand animating the sprites, so that information is really more for him. For a second question, I am attempting to build a test level, and need some pointers. The way I see it I have a few options.
    1. Model the entire board in 3DS, bake textures and import into unity.
    2. Model only assets such as trees, rocks, etc. and sculpt the actual ground of the level in Unity, then attempt to texture that in Unity.
    3. Sculpt the level in Mudbox so I can paint textures and have freedom with ground design, go to max and bake the normals, create other models and add to scene in Max, then render the entire level as an image that I can use in Unity.

    These are all just guesses, but what would be a good pipeline to create the level? Am I even close here or is there a better way?
     
  8. Savage_Games

    Savage_Games

    Joined:
    Dec 17, 2012
    Posts:
    4
    Also, how should I handle the camera, I figure perspective locked to the x axis, tilted at 30* should be good. I just need a starting point to design the test level.
     
  9. Mordekai

    Mordekai

    Joined:
    Nov 8, 2009
    Posts:
    24
  10. FersutaGames

    FersutaGames

    Joined:
    Apr 18, 2013
    Posts:
    20
unityunity