Portals

Let’s see if we can make the flags load another scene, af if the flag is a “portal” that transports the player to the other scene.

First we need a scene and script for the flag node.

Open in editor

New Inherited

This is necessary because we don’t actually have a scene for flag yet. It’s used directly from the Blender asset.

Add ChildNode

It should look like this:

Child Nodes

New CylinderShape3D

Cylinder Sized

Flag Add Script

Connect Signal

  1. Press the Connect button
extends Node3D

signal captured
@export_file("*.tscn") var load_scene: String

func _on_area_3d_body_entered(body):
	# Wait a bit to allow the player to "land" on the flag
	await get_tree().create_timer(0.15).timeout

	# Fly up for half a second
	body.gravity = -100
	captured.emit()
	await get_tree().create_timer(0.5).timeout

	if load_scene and get_tree():
		get_tree().change_scene_to_file(load_scene)

You should still see the connected Signal icon in front of func _on_area_3d_body_entered after updating the code. Otherwise, go back and check the signals!

We need to replace the Flag node with our new flag Scene.

Instantiate Child Scene

Select flag.tscn

You will now have two flags under each other. That’s OK, because this means that our new flag gets the position of the original flag!

Two Flags

It will get renamed to flag2 to avoid duplicate names.

One Flag Again

Load Scene Property

Now, it’s probably a good time to make more levels so this can become a proper game.

If you get issues immediately when you start the game, check that you don’t have platforms or other objects interfering with your flag’s collision cylinder.

Another way to avoid this problem is to set different Collsion Masks

If you want to have the player fall down on loading of the target scene: