holoride
Search Results for

    Show / Hide Table of Contents
    ❮ The Candidate Spawning Strategy
    Scene Generation Events ❯

    Swapping Scenes (Faking a Journey)

    If your experience requires the passenger to travel through vastly different thematic landscapes (like progressing from a peaceful medieval Hobbit Town, through the towering white peaks of Gondor, to the volcanic crags of Mordor), you can implement dynamic Unity Scene-swapping to fake a massive journey—even if the physical vehicle is parked or driving in circles in the exact same neighborhood!

    Because the underlying spatial coordinates and graph parameters are bound to your active local generation bounds, you should not attempt to swap graph references programmatically on a single active generator. Instead, the correct, production-recommended design pattern is to load a completely new Unity Scene in the background.

    Each separate Unity Scene is pre-built and pre-configured with its own Elastic Scene Generator component, its own unique Elastic Graph asset, and its own styled 3D model prefabs!


    The Game Design Recipe

    Step 1: Build Separate Unity Scenes

    Create separate Unity Scenes for each of your thematic "levels" or progression zones:

    • Hobbit Town Scene: Built with an ESG pointing to a graph configured with soft Perlin rolling hills, lush green grass texturing, and round-doored huts.
    • Gondor Scene: Built with an ESG pointing to a graph configured with sharp, tall mountain ridges, white marble textures, and stone citadel structures.
    • Mordor Scene: Built with an ESG pointing to a graph configured with barren basalt crags, lava-river shader masks, and dark iron tower prefabs.

    Step 2: Trigger the Transition

    Track your game's progression metric (e.g., elapsed time, score, or checkpoint markers) inside your runtime manager.

    Step 3: Use Visual Fades

    Use visual transitions (such as our Background Fading extension packages or a custom fullscreen screen fade) to smoothly blend the camera to black, hiding the scene unloading process.

    Step 4: Load the Scene in the Background

    While the screen is black, use Unity's standard SceneManager API to asynchronously load your next pre-configured Scene:

    using UnityEngine;
    using UnityEngine.SceneManagement;
    
    public class MyLevelTransitionManager : MonoBehaviour
    {
        public string nextThematicSceneName = "MordorScene";
    
        public void TriggerThematicTransition()
        {
            // Smoothly load the next scene in the background
            SceneManager.LoadSceneAsync(this.nextThematicSceneName, LoadSceneMode.Single);
        }
    }
    
    Important

    Persistent Vehicle via DontDestroyOnLoad:
    When swapping scenes, you do not want to destroy and re-instantiate your Vehicle prefab. Re-creating the vehicle tears down active hardware connections, resets head-tracking calibrations, and interrupts the passenger's telemetry stream.

    • The Solution: Attach a simple C# script to your root Vehicle GameObject and call DontDestroyOnLoad(gameObject) on scene startup to keep the vehicle persistent across scene swaps.
    • The Re-Linking Requirement: Since the newly loaded scene contains a brand-new ElasticSceneGenerator (ESG) component, you must re-link your persistent Vehicle transform as the ESG's Generation Origin on load. You can handle this re-linking dynamically in a lightweight script attached to your new scene's ESG:
      private void Awake()
      {
          var esg = GetComponent<ElasticSceneGenerator>();
          var vehicle = FindObjectOfType<Vehicle>(); // Find the persistent vehicle instance
          if (vehicle != null)
          {
              // Re-link the persistent vehicle as the scene generation center!
              esg.GenerationOrigin = vehicle.transform;
          }
      }
      

    Step 5: Fade Back In

    Fade the camera back in once the new Scene has completed loading and initialized its generation bounds, instantly placing the passenger inside an entirely different, styled fantasy realm!


    ❮ The Candidate Spawning Strategy
    Scene Generation Events ❯
    In This Article

    Back to top
    ©   holoride
    Privacy   Imprint