0 votes


Instead of using PackedScene[ ], use Array<PackedScene>
[Export] public Array<PackedScene> BottomRooms;
[Export] public Array<PackedScene> TopRooms;
[Export] public Array<PackedScene> LeftRooms;
[Export] public Array<PackedScene> RightRooms;
[Export] public PackedScene ClosedRoom;

Trying to implement a Unity tutorial to Godot (Random Dungeon Generator) in C#

Trying to implement this tutorial to Godot: https://www.youtube.com/watch?v=qAf9axsyijY I have problems.

// ProceduralLevels.cs
// I've tried with Node2D
[Export] public PackedScene[] BottomRooms;
[Export] public PackedScene[] TopRooms;
[Export] public PackedScene[] LeftRooms;
[Export] public PackedScene[] RightRooms;


[Export(PropertyHint.Flags, "Top,Left,Right,Bottom")] public int Pos = 0;

ProceduralLevels levels;
uint randNum;
public bool spawned;
SceneTreeTween tween;
public override void _Ready()
    levels = GetTree().Root.FindNode("Levels", true, false).GetNode<ProceduralLevels>("Levels");
    // levels = FindParent("Levels").GetNode<ProceduralLevels>("Levels");

public override void _Process(float delta)

public void Spawn()
    if (!spawned)
        if (Pos == 0)
            randNum = GD.Randi() % (uint)levels.BottomRooms.Length;
            GD.Print("Spawn::Bottom: ", randNum);
        else if (Pos == 1)
            randNum = GD.Randi() % (uint)levels.TopRooms.Length;
            GD.Print("Spawn::Top: ", randNum);
        else if (Pos == 4)
            randNum = GD.Randi() % (uint)levels.LeftRooms.Length;
            GD.Print("Spawn::Left: ", randNum);
        else if (Pos == 8)
            randNum = GD.Randi() % (uint)levels.RightRooms.Length;
            GD.Print("Spawn::Right: ", randNum);
        spawned = true;

void DetectRooms()
    if (GetOverlappingAreas().Count == 0) return;
    foreach (Area2D item in GetOverlappingAreas())
        if (item.IsInGroup("SpawnPoint"))

Also, in the Unity tutorial is using Invoke(); How to implement Invoke in Godot C#?

Thank you.

Godot version 3.5
in Engine by (37 points)
edited by

Please log in or register to answer this question.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.