moving from one scene to the next automatically

Hello all,

Beginner here:

I am making an experience type app for the vive. The player doesn’t do much but I want them transported to different places for example start standing on a road, then be by a swimming pool then be high in a mountain etc for a few seconds each time. The person pretty much stands still for it.

What is the best way to do this?

  • One large scene and teleport the SteamVR camera rig to different parts of it.
  • Transition between scenes after a fixed number of seconds. A timer that will bring the player into the next scene automatically.

Or something else?

I’m not sure how to do either option or which is the best.

Would appreciate your thoughts and any suggestions.

Thanks

Rob

Fade to black, Load next scene, fade in.

1 Like

From the sound of it there is no reason to have multiple scenes. It sounds like its just basic environments with not much else. I would do fade to black>destroy game object>instantiate game object/new environment>fade in. Or you could easily just build all the environments in one scene with a sky box around each to hide each scene from view. Then simply use player.transform.position (player position) = scenePos.transform.position (position in the new scene).

Out of all these methods there is no wrong way it’s mainly just up to you how you want to do it.

1 Like

Thanks for the replies.

Found a nice simple solution, tried it and it worked…
Video of it:

Code: java script.

#pragma strict

var timer : float = 10.0;

function Update()
{
timer -= Time.deltaTime;

if(timer <= 0)
{
Application.LoadLevel(“Level3”);
}
}

Calls to Application.LoadLevel are deprecated. I’d use the (not-so-new) SceneManager just to be on the safe side.
Since you’re using a timer and you know ahead of time which scenes should be loaded, you could use this example Unity - Scripting API: SceneManagement.SceneManager.LoadSceneAsync along with the essential fadein/out for transitions.

I’d really suggest picking a tutorial and learning the basics :
https://unity3d.com/learn/tutorials

If you insist on learning the basics starting with VR, Unity’s samples have some good reference :

2 Likes

Thanks,
Looks like JavaScript it gone from the new update of Unity!!

Another solution using c# and scene.management

using UnityEngine;
using UnityEngine.SceneManagement;

public class LoadAfterTime : MonoBehaviour
{
[SerializeField]
private float delayBeforeLoading = 10f;
[SerializeField]
private string sceneNameToLoad;
private float timeElapsed;

private void Update()
{
timeElapsed += Time.deltaTime;
if (timeElapsed > delayBeforeLoading)

{
SceneManager.LoadScene(sceneNameToLoad);
}

}
}

Thanks Alex!

2 Likes

My pleasure.

For further interactions on the forum, please use the “Code” tags to make your code less of a hassle to decode :slight_smile: like you can see in this great post : Using code tags properly how it makes it convenient for everyone.