To trigger scene loading or unloading you will need a Collider with IsTrigger set to true and 2 components on it: OnTriggerHandler and SceneController. OnTriggerHandler should expect a tag LocalPlayer. Then make sure to have a scene added as Addressable asset in your Addressable Group window. Now you can open the addressable group and drag the asset into the scene variable on SceneController. Once done, OnTriggerHandler add 2 listeners for On Enter and On Exit events. In both drag and drop the GameObject with SceneController. In the dropdown of functions of event On Enter choose SceneController.TryToLoadNext which will trigger scene loading. The same for On Exit, but instead SceneController.TryToUnloadNext. After that, you GameObject with components should be similar to the one on the image below:

Each created portal must be a child of empty GameObject, which Transform is reseted (position = 0,0,0, rotation = 0,0,0, scale = 1,1,1). Then the GameObject must be saved as prefab and then later marked as addressables. See the video below which shows how such prefab is prepared:

In the video a mistake was made in the last part. Note that Portals prefab was left by accident in the scene, which actually was supposed to be deleted. In other words, NEVER LEAVE THE PORTALS PREFAB IN A SCENE LIKE THIS. Otherwise, it will recursively load the same scene and crash the project at some point.

After setting up the portals, the project is pretty much ready for deployment and testing. So, before making the first build of addressables, you need to create and configure an asset called WorldSettings, which is explained on the next page.

Last updated