Unity3d — How To Change Scenes by Trigger Without Writing Any Code

Brian Mayrose
Jan 9, 2019 · 4 min read

OK, How do we get to another level? The 3D GameKit gives you everything you need to get started, but first, create two scenes and we will explore a quick way to add a trigger to move the character between scenes.

It may be easiest to create a new scene and in your file explorer and just copy and paste it in the same folder just rename each to something like Level1 and Level2, in this case, I named the new scene ‘Level3’.

When you go back into Unity your scene will be automatically added to your project.

Open the new scene you created and go to File > Build Settings and add the newly made scene either by dragging it from the Project window or hitting the ‘add open scenes’ button. Do the same for the other scene also making sure both scenes are in the build setting list

With that out of the way, we can go back to our scene where we want to travel from. With it open, in the project window, search for ‘TransitionStart’, You will see the prefab in the project window, just drag the prefab with that name into your scene.

The Default TransitionStart Prefab

You will only see a green collider box frame. Adjust its position to the area you want to be the trigger to change scenes we will scale it later.

Now find the ‘GateWayHugeTeleporter’ prefab in the Project window and drag it into the scene. Adjust its scale and rotation to what you want and place it behind or in front of the TransitionStart collider.

GateWayHugeTeleporter prefab with the TransitionStart prefab

This way it gives the player an incentive to walk through the ‘TransitionStart’ prefabs collider.

TransitionStart Prefab Inspector Tab Settings

In the Hierarchy, highlight the ‘TransitionStart’ prefab and look at its Inspector tab.

It will have 3 components by default. Transform, Box Collider 2D, and the Transition Point Script.

Since we are working on a 3d game we need to remove the Box Collider 2D. Also, remove the Transition Point Script. Just click the little gear icon in the top right corner of each component.

Now click the Add Component button and search for and add a Box Collider component. Do another search for ‘TransitionPoint’ and add that script component to the TransitionStart prefab also.

Now with the newly added Box Collider added, make sure the ‘Is Trigger’ box is checked and then adjust the scale of the box collider to match the ‘GateWayHugeTeleporter’

Adjust the Box Collider to match the gateway

That is all you have to do for the Box Collider. Next lets set up the Transition Point Script in the Inspector window.

Transition Point Script

First, drag Ellen from the Hierarchy to the ‘Transition Point Script’ slot.

For ‘Transition Type’ select ‘Different Zone’.

Select your new level from the ‘New Scene Name’ drop down. If it is not there then it needs to be added to the build settings.

The ‘Transition Destination Tag is default ‘A’, it can stay like that. You would need to change this if you add another ‘TransitionStart’ Prefab with the tag as A also.

Last we want to set the ‘Transition When’ option to ‘On Trigger Enter’.

That’s all. Go ahead and press play. When you step through the portal you will be transported to your new level. You will also see the default loading screen provided by the 3D Gane Kit.

You can see a video demonstration HERE!

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade