Search Unity

  1. If you have experience with import & exporting custom (.unitypackage) packages, please help complete a survey (open until May 15, 2024).
    Dismiss Notice
  2. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice

Faking a transition from orthographic to perspective camera in Unity 2019.4 LTS?

Discussion in 'Scripting' started by _eternal, Jul 8, 2020.

  1. _eternal

    _eternal

    Joined:
    Nov 25, 2014
    Posts:
    306
    I'm trying to make a "fake" transition between orthographic and perspective modes. Up until now, I was using this ancient script posted in the forums over 10 years ago. This worked in 2019.2, but after upgrading to the 2019.4 LTS, it no longer works. Nothing happens when the script is active.

    Unfortunately, I made the beginner's mistake of pasting some forum code into the game without actually understanding what it does. Indeed, Matrix4x4s are a bit beyond me, and I don't really understand how Unity cameras work outside of the fields exposed in the editor.

    Considering that this script worked up until recently - can you think of any reason why it might not work in 2019.4? Is there a part of that code that's somehow incompatible with the current version of Unity?
    For what it's worth, I'm still using the Built-In Render Pipeline.

    EDIT: Never mind, figured it out. I'll leave this here for the eventual google searches. The problem was that I attached the new Post-Process Layer component to the main camera, and this prevented the projection matrix from changing. I'll look for a workaround now, but it's good to know that the 2009 script still works. The internal workings of a camera's projection matrix probably haven't changed.
     
    Last edited: Jul 8, 2020