# Portals

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:

![](https://4213294372-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fo4sRWPX77c58Cw1FjKCI%2Fuploads%2FJ0D7StuBaD7Kkn3ccPwn%2FSceneLoading.JPG?alt=media\&token=0ff4871f-0e08-48a2-8ea9-127f7bd35fc6)

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:

{% embed url="<https://youtu.be/et5PLUshaZQ>" %}
It also contains part of WorldSettings preparation that will help to understand the next page.
{% endembed %}

{% hint style="danger" %}
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.
{% endhint %}

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.
