-5
\$\begingroup\$

I'm trying to zoom in as my game is like a map and I have to click on a certain country to zoom in and change the scene to this country. So I want to zoom the camera slowly and then change the scene from the map scene to the country scene.

\$\endgroup\$
  • 7
    \$\begingroup\$ With what do you have difficulties with? Zooming? Scene transition? Detecting a click on a country? What you're asking is very broad.... \$\endgroup\$ – Vaillancourt Jun 17 '16 at 19:19
0
\$\begingroup\$

Well, the title is "Zoom In and Switch Scenes", so I'm gonna tell you how to do both of those.

In order to achieve a zoom effect, you'll need to modify the field of view of the camera, which I believe is simply called camera.fieldOfView.

To change scenes, you'll first need to make sure that you are

using UnityEngine.SceneManagement;

So that you can use the SceneManager class, then call:

SceneManager.LoadScene("insert name of your scene here");

To load a specific scene.

To do one and then the other, increment the field of view over several frames, either using Update() or with a Coroutine or some such, then, after the field of view has reached a certain value, load the new scene. So you zoom in over a number of frames, then load.

\$\endgroup\$
  • 1
    \$\begingroup\$ Probably also worth mentioning that you can load one scene into another (e.g. you could load a country on top of a map), by using the mode as a sceond argument to LoadScene \$\endgroup\$ – hobnob Jun 21 '16 at 13:31
  • \$\begingroup\$ Ooh, yes, additive scene loading, didn't think about that. That would look really cool, zooming in from a map and then having the country load in as you got closer with no sudden, jumpy transitions or a fade to black. I like it. +1 for you, good sir. Or madam. I can't see you. \$\endgroup\$ – DisturbedNeo Jun 21 '16 at 13:33
  • \$\begingroup\$ Additive scene loading may be slow enough to make the camera animation extremely choppy. It was in earlier versions of Unity, but I haven't tried it in 5.x yet. Is this currently kosher? \$\endgroup\$ – piojo Dec 7 '16 at 3:12
  • \$\begingroup\$ To use Additive scene loading but without affecting the scene you currently have loaded, I would say use SceneManeger.LoadSceneAsync, using the additive loadscenemode.That way, it loads your new scene in the background, and when it's done, it adds it to the current scene, so it shouldn't affect the camera animation (in theory). You can also use allowSceneActivation in the AsyncOperation to delay the scene actually being activated if you want. \$\endgroup\$ – DisturbedNeo Dec 7 '16 at 10:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.