Enter A Door And Load Next Or Previous Scene Feature For Your 2D Game Made With Unity Software @AlexanderZotov
Enter A Door And Load Next Or Previous Scene Feature For Your 2D Game Made With Unity Software  @AlexanderZotov
Uploaded August 2021 | Updated September 2026, 3 weeks ago
#unityloadscene #unityenterdoor
In this video I show you a simple way to make your character enter a door and load another scene by pressing Enter button on your keyboard.

I play games here - twitch.tv/zzotoff
You are very welcome :-)

Thank you :-)

Project Files Here drive.google.com/file/d/1-MjL_7_FcdBMEQ_Yw3CpAL-cqxWXadYp/view?usp=sharing

Let me start from an empty project and quickly set it up. First I create a new scene and rename it as Level 1. Then I duplicate it by pressing Ctrl+D keys and rename this new scene as Level 2. To make it possible to load any scene I need to add it to the build. File - Build settings - select these two scenes and D&D them into this window. Select level one. I need a character to play with. Here it is. Set Order in layer to 5 for example so the character appears above the door. I add rigidbody 2d component that will help my to move my character and detect collisions. Set gravity scale to zero so character will not fall down. Next component will be a box collider 2d. Set it as a trigger and edit it a bit. This collider will detect doors. My character needs a script to move. Here it is. It’s a simple script that allows me to move my character left and right. Script goes to my man. Another script named Enter door helps my to detect doors and enter them by pressing Enter key. So when my character collides with a door ontrigger enter 2d method is invoked. If my man collides with blue door then level 2 should be loaded. If he collides with brown door then level 1 should be loaded. Enter allowed variable is needed to let my man enter a door only if he collides with it. On trigger exit is invoked when my man exits door collider. When it happens enter allowed is set to false. And in Update method I check if enter is allowed and if enter key is pressed at the same time. If those conditions are met then the scene is loaded. Script also goes to man. This character will be spawned every time a new scene is loaded. So to make it possible I need a prefab of my man. D&D him to project folder to create a prefab. This man from hierarchy can be removed. Now I create a door. Here is the blue one. Door needs a collider. Set it as a trigger. Edit it a bit. Each door will be spawning my character. So this Spawn man script will help me with that. So when a scene is loaded a new man is instantiated at the door's position. Serialize field helps me to assign man prefab in the inspector. I’ll do it later. Script goes to blue door. Also blue door will have blue door script which is just empty one that helps my man to identify this door as blue one. Script goes to blue door as well. And finally I add a simple UI text to the scene that just tells me that this is level 1. Level 1 is ready. Save it and select level 2. This level is the same as the first one. So I do the same steps to set it up. Add brown door. Add collider. Add spawn man script and add brown door script which is also an empty one. And add a simple text. The last thing to do is to assign that man prefab to spawn it. Select door and D&D man prefab to this man slot of spawn man script. Save level 2. Select level, select blue door and D&D man prefab to man slot. Save the scene. Now I can hit play and see how it works. I can move my character left and right and step closer to the door and hit enter then the corresponding scene is loaded.
Enter A Door And Load Next Or Previous Scene Feature For Your 2D Game Made With Unity SoftwareSimple Eyes Blinking Idle Animation For 2D Character In Game Made With Unity Software | Easy WayAMAZING PHONE STAND or HOLDER IN 5 SECONDS VERTICAL AND HORIZONTAL | DIY | ORIGAMIHow To Detect Swipe And Tap Touch Gestures In Android Game Made With Unity Software To Control ItUnity Tutorial How To Move Gameobject With Offset Between Touch Position And Objects PositionHow To Move A Game Object With Arrow Keys In A Game Made With Unity Software? Simple Tutorial.How To Play Different Random UI Button Sounds When Its Clicked In Unity Game | Simple TutorialThe Best 2D Zombie Shooter Game Ever Existed Made With Unity Software Or At Least It Could BeTutorial How To Jump 3D Object With Swipe By The Screen In Mobile Unity Software Game Android Or iOSUnity Tutorial How To Load Next Or Previous Scene In Your Game Using Some Triggers And Scene ManagerUnity 2D Tutorial How To Make Jetpack Feature For Android Game | Hold Finger Down Character Goes UpLets play!
Alexander Zotov |

Enter A Door And Load Next Or Previous Scene Feature For Your 2D Game Made With Unity Software

SHARE TO X SHARE TO REDDIT SHARE TO FACEBOOK WALLPAPER