Spawning additional rooms

Hello, I`ve just finished random dungeon generator from this video

Sadly I have some troubles with it. My rooms are spawning on top of other rooms and it keeps going infinite.

5571433–574909–RoomTemplates.cs (267 Bytes)
5571433–574912–RoomSpawner.cs (1.62 KB)

So i just downloadet your Files and also went to the .git of the tutorial giver,

i needet 2 mins to see that your “RoomSpawner” isnt compete,

if you have issues, maybe check out the .git of the tutorial maker and see whats wrong

Thanks but now I have another problem.
Instantiate(templates.closedRoom, transform.position, Quaternion.identity);
in this line I’m spawning closedRoom but can I change it’s x and y position in the same line? I just need it to be like 2 points higher.

You can make an offset vector and add it to transform.position, something like this:

Vector3 offset = new Vector3(0, 0.2f, 0);
Instantiate(templates.closedRoom, transform.position + offset, Quaternion.identity);

Then just adjust the offset until you like how it looks.

Thank you so much, I’m pretty new to C# and unity may I ask you how long did it take you to understand the code, becouse now I’m just watching those videos and copying code. Could you also give me tips for learning faster?

Personally, I studied Computer Science at a university for 4 years and learned about Unity in my free time for about 3 of those years. I then worked with Unity professionally for about 7 years to date. That’s a long time, but don’t let that discourage you. The hardest part is the beginning, trying to learn all of the concepts you need for the project you’re working on. No one stops learning either; yesterday I learned that I had been doing something the hard way for years that C# has a built-in way of handling. To learn faster, I recommend that you take some free courses on general programming in C#. If you can remember what it was like when you were first learning to read and write, learning programming is something like that. It takes practice. Try not to copy code from other people; it’s tempting, but you’ll hurt your own knowledge doing that. Once you understand what their code is doing and precisely how it works, then you can start copying, but for the most part try to train yourself to do things yourself.
Some of the free web resources I recommend are:
MIT Open Courseware: Structure and Interpretation of Computer Programs | Electrical Engineering and Computer Science | MIT OpenCourseWare
Quill18’s C# series: youtube.com/watch?v=eycAAKpoJxA&list=PLbghT7MmckI7JAftgv0CUdU4RLNivG6wY
(His stuff is usually quite good, IMHO)
Hackerrank problems: https://www.hackerrank.com/

I have no affiliation with any of these things, I just personally like them.

Well if your copying code - you will never understand it.

You need to just following some c# courses and then try working things out for yourself.

https://learn.unity.com/course/create-with-code

Try following that from beginning to end. By the end you should understand enough to start learning things on your own instead of copying code and not really getting any better.