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

Change the camera from 2d to 3d on a click of a keyboard button.

Discussion in '2D' started by LOLZER123, Jul 15, 2020.

  1. LOLZER123

    LOLZER123

    Joined:
    Mar 21, 2020
    Posts:
    5
    Hi there. I was wondering if there is a way to change the way the camera views the scene from 3d to 2d. I would like to make a platformer that can change from 2 dimensions to 3 dimensions. If this is not very clear, do feel free to ask for clarification. Thanks for your time and help!

    The way I want it to work is if the player presses the "return" key, the camera will change its dimension from 2 to 3.
     
  2. Wezai

    Wezai

    Joined:
    Dec 30, 2016
    Posts:
    74
    There is a way to do that. Cameras have a property called ortographic that changes their mode. If you want a smooth transition you are probably better off using fieldOfView and change those values.

    You need to get a reference to the camera (if you only have one, that would be Camera.main). Then you can just use some conditional checks on an Update() method of your script that checks if a button is pressed. If you don't know how to do that I highly recommend you search some tutorials on the internet / YouTube. There are a lot of button tutorials out there.
     
  3. LOLZER123

    LOLZER123

    Joined:
    Mar 21, 2020
    Posts:
    5
    Thanks so much! I will give it a whirl and get back to you!