The SIMPLEST WAY to Change Scenes in Godot

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
welcome back before we get into the tutorial i just wanted to tell you that i will be uploading a new tutorial one to two times every week so if you have any tutorials for goda that you need then let me know in the comments and i can help you out but let's get started with the scene changing the simplest way to scene change ever in godot and also tomorrow i will be uploading a more advanced version to the trend or a more advanced scene changing video with transitions like all the you know transition stuff which will probably take three times as long but it will look three times as cool we can run around the map we get up close to the door we click enter and we change scenes click enter over here can't but when you get close to the little door here you can way over here can't change scenes but you get close to the door you can change scenes how is this done well here is the tutorial for it all right so the way we get started is i just want to show you what we have in the world so we have a world one and a world two now we're gonna be transitioning in between each world using this door and right here is a little hole that we're gonna come up and out of we also have a player scene but so to start we're just going to go to our world one we're going to want to add a area 2d this is how we are going to be able to detect the player we want to add a collision shape to you know your area too deep you're going to want to put this around the door so for the collision shape i'm just going to use a circle and then we can extend this circle to make it we'll just do something like this so when you get close to the door you can click a button and you'll go through the door into the other world so we'll just do something just like this now we want to go to our area to the add a sign we'll do area 2d uh we'll just area g1 is fine and inside of our area today we are going to first go to our click on the area 2d go to node and we want some of these signals we want body entered and we want body node so make sure it is a body node body entered we will send this straight to the area to d we also want to send a body exited to the area 2d so boom to area 2d and now we have our two signals basically be being sent from the area to the to the area to the aegis so we have it in the script but so we want the body here we want to make sure it's the player's body so we'll do a little thing right here to make sure it's a physics body physics body is going to make sure it is a physics body which is would be a player an npc something like that but physics body would be fine for the player i'm going to make a variable for entered we'll just put enter equals false to start because we always want it to be fast unless there is a body in here so if there is a body in here then we want entered to be equal to true because this means we can click a button to go through the door and if it's not then we want it to be equal to false if there is no body in there now here you don't have to put the physics body to the you can but i don't think it matters much we also want to add a physics process function and we're just going to do if entered equals is equal to true then we want to check for input so now if input dot is action just pressed we'll just go with any you can do any button i'm just yeah i'm just going to go with ui accept now here's the transition phase so whatever you put right here this is everything that leads up to the transition all this stuff i mean obviously it matters to start the transition but it's not really part of the actual one line of transition this is it get tree dot scene so or dot we'll just yeah dot change scene there are multiple ways to do this but this is the easiest way by far and then you want to put whatever scene you're going to so we're going to go to world 2 because right now we are in world 1 and we want to go to world 2. boom that's simple now i'm going to save this but if we play it you will see we can go anywhere around our map if we get in close to the door we click enter now we're in world 2 but there's no way to get back so i'm just going to go over to world 2 we can add a area 2d and basically just repeat the exact same process so area 2d add a collision shape 2d we'll make the cushion shape uh a circle so or just put it some way around here just so it's around this little pothole or the hole with a ladder area 2d we want to add a script we'll do area 2d2 we'll create it we will send the signals that we have to send straight to the area 2d and the exit signal boom we can change the body to be the physics body so we can check for a physics body physics body 2d and i'm actually just going to go back over here we can copy this function right here and then we can add this down here and it will be just fine and then except we want to go to a different world so we'll do to world one because that's the scene we want to transition into and then delete all this junk because it does not matter we can copy the rest of this just like so you can type it in it doesn't matter i'm just doing this because it's much easier and we don't have to type it in boom just make sure you do change the transition scene you can put this in any world just make sure you change this because that's all that matters and then i think that's it we'll give it a play we start off here we can go into this world we can go back to this world but look if we're way over here let me click enter can't go anywhere can't go anywhere get inside the zone you can can't go anywhere i can't go anywhere you can so yeah it's that simple but keep in tune with the channel because tomorrow i'll be uploading the more advanced version with transitions and everything like that thank you guys so much for watching i hope this tutorial did help you guys out and i'll see you next time stay safe and have an amazing rest of your day you
Info
Channel: DevWorm
Views: 41,822
Rating: undefined out of 5
Keywords: godot, game development, godot engine, godot how to make a 2d game, godot how to, godot tutorial, godot how to change scene easy, best way to change scenes in godot, how do you change scenes easy in godot, scene change in godot, how to change scenes in godot, DevWorm, how to, game dev, godot 4
Id: FuIn_1aK7rM
Channel Id: undefined
Length: 7min 36sec (456 seconds)
Published: Sat Jun 04 2022
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.