Godot - Changing the scene

3.3k views Asked by At

I am working on a breakout game and I need to reload the scene when the ball hits a wall. Here is the code:

extends RigidBody2D

func _ready():
    set_fixed_process(true)

func _fixed_process(delta):
    var caramizi = get_colliding_bodies()

    for caramida in caramizi:
        if caramida.is_in_group("caramida"):
            caramida.queue_free()
        elif caramida.is_in_group("die"):
            #reload the scene
            pass

How to reload the scene?

1

There are 1 answers

0
Cody Parker On BEST ANSWER

The SceneTree has a reload_current_scene method. You should be able to use it with:

get_tree().reload_current_scene()

http://docs.godotengine.org/en/stable/classes/class_scenetree.html