• Home
  • News
  • Software
  • Knowledge
  • MMO
  • Tips
  • Security
  • Network
  • Office
AnonyViet - English Version
  • Home
  • News
  • Software
  • Knowledge
  • MMO
  • Tips
  • Security
  • Network
  • Office
No Result
View All Result
  • Home
  • News
  • Software
  • Knowledge
  • MMO
  • Tips
  • Security
  • Network
  • Office
No Result
View All Result
AnonyViet - English Version
No Result
View All Result

[Tạo 2D Platformer Game với Godot] Part 9: Moving between levels

AnonyViet by AnonyViet
January 27, 2023
in Tips
0

In this part, I will show you how to be able to move between levels 1,2,3,etc when reaching the end of a level.

Join the channel Telegram of the AnonyViet 👉 Link 👈

Create New Scene

[Tạo 2D Platformer Game với Godot]  Part 9: Moving between levelsFirst, you create a new Scene with Area2D as the root node.

Here, I use Area2D because I will create an area and when the PLAyer enters it will move to the next level.

[Tạo 2D Platformer Game với Godot]  Part 9: Moving between levels 31

Done, then save it in the Scene folder.[Tạo 2D Platformer Game với Godot]  Part 9: Moving between levels 32

Next, add the script to it.

The script includes the following:

extends Area2D


export (String,FILE) var LevelKeTiep


func _on_KhuVucDiChuyen_body_entered(body):
    if body.name == "Player":
        get_tree().change_scene(LevelKeTiep)

I declare a variable and this variable is special where I use it export(this is the command that will make the variable appear outside the Inspector so it can be easily edited)

[Tạo 2D Platformer Game với Godot]  Part 9: Moving between levels 33I add (String,FILE) behind to be able to select files from outside the Inspector.

You can find more documentation here: GDScript exports

As for the function below, you have to connect signal to appear.

if body.name == “Player” is that I check that if the Body comes in and the name is Player (name of the character scene that you and I created), it will move to the Level assigned to the above variable.

[Tạo 2D Platformer Game với Godot]  Part 9: Moving between levels 34

You click on Area2D

[Tạo 2D Platformer Game với Godot]  Part 9: Moving between levels 35

Through the Node tab, click 2 and click on the enter body (here I use the body entered because the Player is a KinematicBody2D, so I will use the signal to determine when a body enters Area2D)

[Tạo 2D Platformer Game với Godot]  Part 9: Moving between levels 36

The table that appears, select Area2D and then click Connect.

[Tạo 2D Platformer Game với Godot]  Part 9: Moving between levels 37 [Tạo 2D Platformer Game với Godot]  Part 9: Moving between levels 38

You can know that the signal has been connected successfully by looking at the two symbols in the two pictures above.

New Level

After you’re done, create yourself a new level similar to how you create a Scene Map.[Tạo 2D Platformer Game với Godot]  Part 9: Moving between levels 39

After creating a new 2D node, rename it to map2.

[Tạo 2D Platformer Game với Godot]  Part 9: Moving between levels 40

And instead of redoing the tilemap you can go to the first map to copy it.

[Tạo 2D Platformer Game với Godot]  Part 9: Moving between levels 41

Go to map 2 and paste it out.

[Tạo 2D Platformer Game với Godot]  Part 9: Moving between levels 42

After pasting, we get the same tilemap as the first Map and you just need to adjust it[Tạo 2D Platformer Game với Godot]  Part 9: Moving between levels 43

My Map 2 after editing.

[Tạo 2D Platformer Game với Godot]  Part 9: Moving between levels 44

Add Player and Background like Map 1, copy it and you’re done.

Instance teleportation area

[Tạo 2D Platformer Game với Godot]  Part 9: Moving between levels 45

You Instance node has just moved to Map1 [Tạo 2D Platformer Game với Godot]  Part 9: Moving between levels 46

Right-click and select editable children to edit it.

[Tạo 2D Platformer Game với Godot]  Part 9: Moving between levels 47

[Tạo 2D Platformer Game với Godot]  Part 9: Moving between levels 48

Select CollisionShape2D and select its shape.

[Tạo 2D Platformer Game với Godot]  Part 9: Moving between levels 49

After selecting the shape, it will appear like this.

[Tạo 2D Platformer Game với Godot]  Part 9: Moving between levels 50

And you drag it to the place where we need to change the level by clicking on the Area and clicking the move icon on the toolbar, but don’t drag the CollisionShape2D away.

[Tạo 2D Platformer Game với Godot]  Part 9: Moving between levels 51

I have moved to the position I want and I edited the CollisionShape2D so that it is reasonable.

[Tạo 2D Platformer Game với Godot]  Part 9: Moving between levels 52

You won’t be able to move yet because you haven’t told it which scene you want to move through, so in KhuVucDichChuyen click on the folder icon.[Tạo 2D Platformer Game với Godot]  Part 9: Moving between levels 53 [Tạo 2D Platformer Game với Godot]  Part 9: Moving between levels 54
[Tạo 2D Platformer Game với Godot]  Part 9: Moving between levels 55

Find and select Map2 then click Open.

[Tạo 2D Platformer Game với Godot]  Part 9: Moving between levels 56

Once done, Map2 has been added to the LevelKeTiep variable[Tạo 2D Platformer Game với Godot]  Part 9: Moving between levels 57

[Tạo 2D Platformer Game với Godot]  Part 9: Moving between levels 58

Above, when I enter, I will be transferred to Map2.

Here, you can apply many ways to make the most of it, such as:

  • Set camera limit in front of the moving area
  • Add Sprite in Scene KhuVucDiChuyen for easy identification.

summary

In this section, I have shown you how to move between levels together and depending on your creativity and understanding, you can design many other things.

The article achieved: 5/5 – (100 votes)

Tags: GameGodotLevelsmovingPartPlatformertạovới
Previous Post

How to use Warp+ unlimited data with CloudFlare Teams

Next Post

What is repeater? How to configure Wifi Xiaomi Repeater version 2

AnonyViet

AnonyViet

Related Posts

4 ways to fix bluetooth connectivity on Windows 11
Tips

4 ways to fix bluetooth connectivity on Windows 11

August 8, 2025
How to know the computer is tracked and processed by Keylogger
Tips

How to know the computer is tracked and processed by Keylogger

August 7, 2025
Opal: Create applications who do not need to write code
Tips

Opal: Create applications who do not need to write code

August 3, 2025
How to activate a new Start menu on Windows 11
Tips

How to activate a new Start menu on Windows 11

July 29, 2025
Intellgpt: AI tool for osint and data science
Tips

Intellgpt: AI tool for osint and data science

July 28, 2025
How to create Google Ai Pro 12 months free with Indian student account
Tips

How to create Google Ai Pro 12 months free with Indian student account

July 27, 2025
Next Post
What is repeater?  How to configure Wifi Xiaomi Repeater version 2

What is repeater? How to configure Wifi Xiaomi Repeater version 2

0 0 votes
Article Rating
Subscribe
Login
Notify of
guest

guest

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments

Recent News

How to add application to your favorite bar

How to add application to your favorite bar

August 14, 2025
Wowhay.com – The door opens the world of modern knowledge and network culture

Wowhay.com – The door opens the world of modern knowledge and network culture

August 13, 2025
Instructions on how to fix Screen Time Limited Reached on RoBlox

Instructions on how to fix Screen Time Limited Reached on RoBlox

August 13, 2025
How to install GPT-suns on who do not need the Internet

How to install GPT-suns on who do not need the Internet

August 12, 2025
How to add application to your favorite bar

How to add application to your favorite bar

August 14, 2025
Wowhay.com – The door opens the world of modern knowledge and network culture

Wowhay.com – The door opens the world of modern knowledge and network culture

August 13, 2025
Instructions on how to fix Screen Time Limited Reached on RoBlox

Instructions on how to fix Screen Time Limited Reached on RoBlox

August 13, 2025
AnonyViet - English Version

AnonyViet

AnonyViet is a website share knowledge that you have never learned in school!

We are ready to welcome your comments, as well as your articles sent to AnonyViet.

Follow Us

Contact:

Email: anonyviet.com[@]gmail.com

Main Website: https://anonyviet.com

Recent News

How to add application to your favorite bar

How to add application to your favorite bar

August 14, 2025
Wowhay.com – The door opens the world of modern knowledge and network culture

Wowhay.com – The door opens the world of modern knowledge and network culture

August 13, 2025
  • Home
  • Home 2
  • Home 3
  • Home 4
  • Home 5
  • Home 6
  • Next Dest Page
  • Sample Page

©2024 AnonyVietFor Knowledge kqxs hôm nay xem phim miễn phí mm88 8XBET mm88 trang chủ new88

No Result
View All Result
  • Home
  • News
  • Software
  • Knowledge
  • MMO
  • Tips
  • Security
  • Network
  • Office

©2024 AnonyVietFor Knowledge kqxs hôm nay xem phim miễn phí mm88 8XBET mm88 trang chủ new88

wpDiscuz
0
0
Would love your thoughts, please comment.x
()
x
| Reply