Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

2d perspective with 3d depth

Discussion in 'General Discussion' started by IE-online-Entertainment, Jan 5, 2015.

  1. IE-online-Entertainment

    IE-online-Entertainment

    Joined:
    Feb 3, 2014
    Posts:
    28
    Hello, I was wondering if you guys could help me out. I'm in the early stages of development on my game and I was wondering if it is possible to use a 3d depth of field while using the Unity 2d mode? Here is what I mean.

    My game is a 2d platformer so it is viewed in the classic 2d side view. I want the background layers to be displayed in the correct depth so if i make a mountain to scale, i want to stick it far enough in the background so that it is scaled in the distance. The reason being is that I want the player to be able to jump into the background. I realize this can be done but just wasnt sure if you use the 2d perspective that means losing any 3d depth while maintaining a proper 2d illusion. Does any of this make sense? I appreciate any feedback.
     
  2. N1warhead

    N1warhead

    Joined:
    Mar 12, 2014
    Posts:
    3,884
    Just change the Camera from Orthographic to Prospective, that's the only way I can see it properly done, so you would technically have a 2.5D game... But from what I've seen an Orthographic camera works, but it doesn't allow any depth that I can tell that makes it show 3d depth.
     
  3. IE-online-Entertainment

    IE-online-Entertainment

    Joined:
    Feb 3, 2014
    Posts:
    28
    Now, I know it will work as you have stated but what Im wondering is if the camera will show the edges of my sprites since everything in my scene is a 2d sprite.
     
  4. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    There isn't really any 2D mode. Everything in Unity is 3D, even if you put the scene view in 2D mode. So yes just use a perspective camera; it works fine. Example

    --Eric
     
    senkal_ likes this.
  5. IE-online-Entertainment

    IE-online-Entertainment

    Joined:
    Feb 3, 2014
    Posts:
    28
    Now i played the game. That looks like what Im talking about. Is that just using a perspective camera instead of the 2d?
     
  6. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    The camera is using perspective instead of orthographic, yes.

    --Eric
     
  7. N1warhead

    N1warhead

    Joined:
    Mar 12, 2014
    Posts:
    3,884
    Yeap yeap yeap..

    Just change the field of view if you want it more almost like an ortho cam. It will condense the image, so you may have to move camera back a little bit to desired effect.

    (what I said is untested) just an assumption, so just remember your settings.
     
  8. IE-online-Entertainment

    IE-online-Entertainment

    Joined:
    Feb 3, 2014
    Posts:
    28
    Cool. Now the camera won't show the edges of the sprites at any point? Also, could you technically zoom in and out of background if the game required the player to jump between foreground and background?
     
  9. IE-online-Entertainment

    IE-online-Entertainment

    Joined:
    Feb 3, 2014
    Posts:
    28
    Cool. Thanks a lot.
     
  10. IE-online-Entertainment

    IE-online-Entertainment

    Joined:
    Feb 3, 2014
    Posts:
    28
    Thanks for the reply guys. You are a big help
     
  11. N1warhead

    N1warhead

    Joined:
    Mar 12, 2014
    Posts:
    3,884
    No problem buddy
     
  12. Not_Sure

    Not_Sure

    Joined:
    Dec 13, 2011
    Posts:
    3,541
    One quick tip: you can do all of your physics in 2d, but just attach them to 3d object. 2d physics just ignores the Z axis, which saves on CPU. However that does mean that if two objects pass each other on the X and Y axis, but are not touching on the Z axis, Unity will still register that as a collision.

    If that makes sense...
     
  13. IE-online-Entertainment

    IE-online-Entertainment

    Joined:
    Feb 3, 2014
    Posts:
    28
    Ok. Cool. Thanks for the tip. I appreciate it.
     
  14. angrypenguin

    angrypenguin

    Joined:
    Dec 29, 2011
    Posts:
    15,516
    What do you mean by "show the edges of the sprites"? Sprites don't have depth, so they won't look like cardboard cutouts on standees (with thickness) if that's what you're asking about.
     
  15. IE-online-Entertainment

    IE-online-Entertainment

    Joined:
    Feb 3, 2014
    Posts:
    28
    Thats actually what i was thinking. I was hoping that when the camera moves that it didnt show any edges. So your saying while the game is running, the sprites will look flat no matter where the sprites are?
     
  16. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    Sprites are textures on quads, so, being 2-dimensional, it's impossible to see "edges" under any circumstances. Put a sprite in the scene view, then move the camera around (with 2D mode off) and tell me what you see.

    --Eric
     
  17. IE-online-Entertainment

    IE-online-Entertainment

    Joined:
    Feb 3, 2014
    Posts:
    28
    Ok. I will do that. Thanks for your input.