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. Dismiss Notice

Question Mixing 3D objects in a 2D game

Discussion in 'Scripting' started by warrenbrandt, Mar 27, 2023.

  1. warrenbrandt

    warrenbrandt

    Joined:
    Mar 3, 2018
    Posts:
    413
    I love this idea,

    I have a 2D sprite guy walking around and the camera is at a top down view.
    Then I have a few 3D houses etc, looks neat.

    The only problem im having is that everything is correct when its in 2D mode, but when i switch to 3D, my 2D is facing 90 degrees up from the grid. Its really hard to navigate and place 3D objects when you facing the wrong way. How can I correct this?
     
  2. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    36,758
    Warren!! I am really struggling to visualize what you describe.

    Could you perhaps add a few small screencaps to show what you mean?? Just attach them as images in your reply and then you can write text around them, explain them.
     
  3. chemicalcrux

    chemicalcrux

    Joined:
    Mar 16, 2017
    Posts:
    717
    I think the problem is that 2D mode works in the XY plane, which winds up being vertical in 3D mode.
     
    warrenbrandt likes this.
  4. warrenbrandt

    warrenbrandt

    Joined:
    Mar 3, 2018
    Posts:
    413
    Hi guys

    Exactly that, i even tried putting everything under one game object then rotating that, it broke my controllers obviously but still doesnt work right.
     
  5. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    36,758
    There really isn't any 3D mode, and hence there's no 2D mode.

    It's all just Unity3D.

    By internal plumbing convention Unity maps the Physics2D engine to the X/Y plane. I'm not privy to how, but I assume they just map the x/y coming out of Box2D engine into the x/y of the Transform.

    Default gravity is in the -Y direction both for 2D and 3D Physics. It can be changed to anything.

    By default scene convention the default camera looks +Z (both ortho (for 2D) and perspective (for 3D) )

    You can put sprites at any orientation you like. Remember sprites are visible from both sides by default.

    You can build 3D stuff at any orientation you like.

    You could point the camera in pretty much any direction you want.

    Believe it or not you can even present a 2D physics game in the X/Y plane as objects moving in the X/Z plane if you like, just by making visible objects without any physics that track the 2D physics objects.

    So... wot I am saying is, you CAN get what you want working, but again, I still have no idea what exactly you want.
     
    Bunny83 likes this.
  6. QuinnWinters

    QuinnWinters

    Joined:
    Dec 31, 2013
    Posts:
    490
    I'm guessing he's talking about what I posted a screenshot of below, which appears to illustrate his description of the issue with the camera being "top down" in 2D scene view and the sprites at a 90 degree angle from the grid in 3D scene view.



    3D objects position very oddly when working in that 2D scene view. The way to deal with that is to always work in a 3D scene view and consider your 2D an XY plane that the camera faces. If you prefer working in top-down mode like that 2D scene view appears, just face your camera down and have your 2D on an XZ plane.
     
  7. warrenbrandt

    warrenbrandt

    Joined:
    Mar 3, 2018
    Posts:
    413
    Yes you are both right, not to mention moving around in 3D view is all ass about face when trying to navigate. But I could live with it.