Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by dinobert10 · Jan 08, 2018 at 11:40 PM · dimensions

I want to make a game where you can switch from 2D 8 bit to 3D third person by going through a door. How would I code this?

Could I make two separate cameras and 2 areas for 8 bit and 3D?

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by KittenSnipes · Jan 09, 2018 at 10:02 PM

@dinobert10

What have you tried so far? I played around a bit and at least figured out a hard part for you. The switch from 3d cam to 2d. So here you go:

 using UnityEngine;
 
 [RequireComponent(typeof(Camera))]
 public class CameraProjectionChange : MonoBehaviour
 {
     public float ProjectionChangeTime = 0.5f;
     public bool ChangeProjection = false;
 
     private bool _changing = false;
     private float _currentT = 0.0f;
 
     private void Update()
     {
         if (Input.GetKeyDown(KeyCode.Tab))
         {
             ChangeProjection = !ChangeProjection;
         }
 
         if (_changing)
         {
             ChangeProjection = false;
         }
 
         else if (ChangeProjection)
         {
             _changing = true;
             _currentT = 0.0f;
         }
     }
 
     private void LateUpdate()
     {
         if (!_changing)
         {
             return;
         }
 
         var currentlyOrthographic = GetComponent<Camera>().orthographic;
         Matrix4x4 orthoMat, persMat;
         if (currentlyOrthographic)
         {
             orthoMat = GetComponent<Camera>().projectionMatrix;
 
             GetComponent<Camera>().orthographic = false;
             GetComponent<Camera>().ResetProjectionMatrix();
             persMat = GetComponent<Camera>().projectionMatrix;
         }
         else
         {
             persMat = GetComponent<Camera>().projectionMatrix;
 
             GetComponent<Camera>().orthographic = true;
             GetComponent<Camera>().ResetProjectionMatrix();
             orthoMat = GetComponent<Camera>().projectionMatrix;
         }
         GetComponent<Camera>().orthographic = currentlyOrthographic;
 
         _currentT += (Time.deltaTime / ProjectionChangeTime);
         if (_currentT < 1.0f)
         {
             if (currentlyOrthographic)
             {
                 GetComponent<Camera>().projectionMatrix = MatrixLerp(orthoMat, persMat, _currentT * _currentT);
             }
             else
             {
                 GetComponent<Camera>().projectionMatrix = MatrixLerp(persMat, orthoMat, Mathf.Sqrt(_currentT));
             }
         }
         else
         {
             _changing = false;
             GetComponent<Camera>().orthographic = !currentlyOrthographic;
             GetComponent<Camera>().ResetProjectionMatrix();
         }
     }
 
     private Matrix4x4 MatrixLerp(Matrix4x4 from, Matrix4x4 to, float t)
     {
         t = Mathf.Clamp(t, 0.0f, 1.0f);
         var newMatrix = new Matrix4x4();
         newMatrix.SetRow(0, Vector4.Lerp(from.GetRow(0), to.GetRow(0), t));
         newMatrix.SetRow(1, Vector4.Lerp(from.GetRow(1), to.GetRow(1), t));
         newMatrix.SetRow(2, Vector4.Lerp(from.GetRow(2), to.GetRow(2), t));
         newMatrix.SetRow(3, Vector4.Lerp(from.GetRow(3), to.GetRow(3), t));
         return newMatrix;
     }
 }


After that I need a bit more info because this is a pretty vague question. I would like to know what you have thought up so far and what you are planning to do. It would help me help you more.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

74 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

AddForce ignores X and Y components 0 Answers

How to teleport an object relative to itself 0 Answers

Change texture non-power of 2 setting at runtime? 1 Answer

Rendering specific layers inside sprite 0 Answers

Unity 4.6 UI Canvas width & height 2 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges