#levels

1 messages · Page 1 of 1 (latest)

weary jolt
#

i want to use areabody3d to move my player to a different scene

#

kinda like the milk in karlson

knotty crater
#

Do you need to keep data between levels? Is your game only linear?

It could be as simple as a change_scene() when your player enter within area.

If you need to keep data, you may need something to handle transition (it should store data, erase the current scene and load the next)

weary jolt
#

I just need to move my 3d player to the next level

knotty crater
#

One way could be to follow those steps

  1. Create a script for your Area3D
  2. Within this script add an export variable of type String, you will use this to set the path for loading the next level (Each level should have is value set manually in the inspector)
  3. Also add a const of type String with the path to a folder where all levels will be stored
@export var next_level : String = "" # By default it's an empty string
const path : String = "res/levels" # You can copy and paste the name
  1. Connect the body_entered signal to a function (with the inspector or by code)
  2. Within this function you concanate path and next level then change_scene with this ref
func change_level():
  if next_level != "" # if no value has been set, nothing happen.
    var scene : String = path+next_level
    SceneTree.change_scene_to_file(scene)

NB For this to work as expected, you need to have an instance of your player in the stored scene or created at the start of the level. This code only change the current scene.

weary jolt
knotty crater
#

Not a crash but blank? Do you have a player and a camera in the next level?