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

How to implement Sprites in a 2.5D game

Discussion in '2D' started by Anerx, Nov 20, 2013.

  1. Anerx

    Anerx

    Joined:
    Nov 16, 2013
    Posts:
    2
    I apologize if this has already been answered, but I couldn't find a solution to this problem searching the forums or google. I should also point out that I am a total beginner in Unity and the solution may be really simple, but yet it escapes me.

    So here's the deal. I want to make a 2.5D game, using only 2D models (Sprites) for my characters, environment etc. Think Captain Commando for example.



    I've tried having a plane for terrain and have my sprites walking on it, but 2D and 3D colliders don't play nice with each other. I came across this suggestion http://forum.unity3d.com/threads/204770-2-5d-sprites :
    But that seems like a waste of the whole Sprite and easy animations system. And since 2D colliders refuse to rotate around the X axis (?), they're out of the question too. Is there a better solution than that one?

    One thing I came up with was to rotate the Sprites and attach them to a plane or similar 3D object and then try to work with 2D unrotated colliders in combination with 3D colliders and somehow make it work, but I hope there's something simpler and easier.

    Thanks for your time
     
    Last edited: Nov 20, 2013
  2. SpiriTx

    SpiriTx

    Graphics QA

    Joined:
    Apr 12, 2012
    Posts:
    252
    You can get isometric view with sprites by changing z coordinate as your y changes.



    Sample code:
    Code (csharp):
    1.  
    2. void Update() //Use Start instead for static objects
    3.     {
    4.         Vector3 position = transform.position;
    5.         position.z = position.y;
    6.         transform.position = position;
    7.     }
    8.  
    Just be careful with colliders, they need to be on the bottom of the object to collide properly. Something like that

     
    Katoblepa likes this.
  3. Anerx

    Anerx

    Joined:
    Nov 16, 2013
    Posts:
    2
    Thank you very much !

    And thank you for the image references, I think I got the concept down
     
  4. bhviid

    bhviid

    Joined:
    Dec 20, 2012
    Posts:
    2
    I'm planning on making something with a similar isometric view.

    Using your method, how would you be able to check if the player is grounded when jumping?
     
  5. TomasJ

    TomasJ

    Joined:
    Sep 26, 2010
    Posts:
    256
    Depends on what you want to achieve. You can always keep the base GO of a player at ground level (think it of a place where the shadow would be) and offset child GOs with renderers and colliders for the jump, then compare heights.
     
    Last edited: Nov 21, 2013