• 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
1
Question by andrewgame2020 · Sep 09, 2020 at 09:29 PM · scene-loadingzoom

Help with 'infinite zoom'

Hi,

I'm wanting to create an infinite zoom - or at least the appearance of one. So something similar visually to (but obviously not a copy of) what monument valley 2 did here: https://streamable.com/8yez8y

I'd really appreciate any advice. I just don't know where to start - is it e.g. about having scenes loads asynchronously to avoid any pause whilst the new one loads?

Any advice appreciated.

Thanks very much

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
1
Best Answer

Answer by Bunny83 · Sep 10, 2020 at 12:35 PM

Well, this is pretty trivial. Since the game you're referring to is an isometric game you can easily layer the different sections on top of each other. Moving them closer or further away from the camera doesn't change their appearance at all. The key is to not move or zoom the camera at all. So the camera and it's properties stay fixed. All you have to do is scale up the different sections all simultaneously. Of course the section furthest from the camera is the largest one. The next one is relatively smaller, say 10%. So the third one would be only 1% of the first size and the fourth one scaled down to 0.1% of the first size. For the animation you just scale them all up at the same time. Once you reached say a scale factor of 100 you can probably remove the first section because it's not visible anymore. At the same time you can push all sections further away from the camera so the second section takes the position of the original first one. Of course as you increase the scale and removing the largest one, you have to spawn new sections on top of all others.


There are a few things to watch out for in order to not mess up. First of all make sure the camera is looking at the origin (0,0,0)- This makes a lot things easier. So using LookAt() would be the easiest solution. You can instantiate the sections in worldspace so they are aligned with the world, and after that you could parent them to the camera. The advantage is that you can now move a section on the local z axis and it will move perfectly in relation to the camera.


I quickly created an example with a couple of section prefabs. I've created a package of the example. Though the only script I used is this one:

 using System.Collections.Generic;
 using UnityEngine;
 
 public class InfiniteZoom : MonoBehaviour
 {
     public List<Transform> sectionPrefabs;
     public float sectionSpacing = 5;
     public float scaleFactor = 0.1f;
     private List<Transform> activeSections = new List<Transform>();
 
     void Start()
     {
         transform.LookAt(Vector3.zero);
     }
     void AddRandomSection()
     {
         int index = Random.Range(0, sectionPrefabs.Count);
         var clone = Instantiate(sectionPrefabs[index]);
         clone.parent = transform;
         clone.localPosition = Vector3.forward * (10-activeSections.Count) * sectionSpacing;
         if (activeSections.Count > 0)
             clone.localScale = activeSections[activeSections.Count-1].localScale * scaleFactor;
         activeSections.Add(clone);
     }
 
     void Update()
     {
         while (activeSections.Count < 10)
             AddRandomSection();
         float scale = Mathf.Pow(2, Time.deltaTime*3);
         for (int i = activeSections.Count - 1; i >= 0; i--)
         {
             activeSections[i].localScale *= scale;
             if (activeSections[i].localScale.x > 1000)
             {
                 Destroy(activeSections[i].gameObject);
                 activeSections.RemoveAt(i);
                 for (int n = activeSections.Count - 1; n >= 0; n--)
                 {
                     activeSections[n].localPosition += Vector3.forward * sectionSpacing;
                 }
             }
         }
     }
 }

The rest is just proper setup of the sections and the camera. Please forgive the coder graphics :) I'm not an artist. Note that the Text section requires TextMeshPro.

Comment
Add comment · Show 2 · 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
avatar image andrewgame2020 · Sep 10, 2020 at 09:11 PM 0
Share

Wow! Thanks so much - that's really so kind of you @Bunny83. Was rather dispirited about it all - can't quite believe the effort you went to on this, not just writing an explanation, but adding code, and then on top of that a web app and the package - really unbelievably kind. I'll look at this properly tomorrow as it's late where I am but I just wanted to reply now to say thank you. Is there a system in unity to actually pay people for their answers? 'Reward user' just seems to offer points which doesn't seem enough.

avatar image Bunny83 andrewgame2020 · Sep 10, 2020 at 11:20 PM 0
Share

I'm not aware of any such "system" you mentioned. UA is just one of my hobbies :) I like solving problems, at least those which are somewhat interesting. For answers here I've written a neural network, a parametric L-System, a shape detector for images, a prove of concept for VisPortals, an ExpressionParser, a doom skybox shader and many other smaller or larger tools and frameworks like an FFT, a B$$anonymous$$P loader, my PNGTools or a Cal3d model loader. Those were all just questions that were quite interesting. UA and the wiki is a perfect place to share such things for the community. Even when some questions seem trivial or too generic it might be the perfect place to teach about matrices, coroutines or Unity's I$$anonymous$$GUI system. Personally I just love Unity as a platform, especially the extensibility of the editor itself.

So there's no need for additional gratitude. Knowledge is meant to be shared :)

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.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

140 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 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

RenderSettings not overwritten when using LoadLevelAdditive 0 Answers

OnSceneLoaded-specifically targeting one scene 1 Answer

Unity short Black Screen after loading scene 1 Answer

Attempting to Create an Essential SceneElements Checker 0 Answers

Which is Light Baking approach is best for maintaining smooth continuous level loading? 0 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