Hi guys I'm trying to recreate this: This is how it looks like: https://pastebin.com/BZe5jRL3 https://pastebin.com/2qsHd7xk The problem is that the "end room" is spawning in the same place where the "start room" is, but it shouldn't of course and I don't understand why, because it looks like everything is the same as in the video.
Some steps to debug: - locate where it spawns the room in the code - find out where it computes the position - make sure that computed position is reasonable - make sure that computed position is assigned to the newly-spawned room. Use Debug.Log(); to track things down, or else attach the debugger and single-step it, your choice really.
So I was looking for the reason for some time and I found out that the whole project is on github. So I copied scripts for generation to check if I made mistake somewhere and... I turns out that I didn't, because now everything is exactly how it is there and it still doesn't work. So I really don't understand why it is not working? https://github.com/chillehh/Binding-of-Isaac-Tutorial
I still didn't solve this problem. I specified what is responsible for spawning "end room" (room with boss) in code: DungeonGenerator Code (CSharp): public class DungeonGenerator : MonoBehaviour { public DungeonGenerationData dungeonGenerationData; private List<Vector2Int> dungeonRooms; private void Start() { dungeonRooms = DungeonCrawlerController.GenerateDungeon(dungeonGenerationData); SpawnRooms(dungeonRooms); } private void SpawnRooms(IEnumerable<Vector2Int> rooms) { RoomController.instance.LoadRoom("Start", 0, 0); foreach(Vector2Int roomLocation in rooms) { RoomController.instance.LoadRoom("Empty", roomLocation.x, roomLocation.y); } } } DungeonCrawlerController: Code (CSharp): ... public static List<Vector2Int> GenerateDungeon(DungeonGenerationData dungeonData) { List<DungeonCrawler> dungeonCrawlers = new List<DungeonCrawler>(); for(int i = 0; i < dungeonData.numberOfCrawlers; i++) { dungeonCrawlers.Add(new DungeonCrawler(Vector2Int.zero)); } int iterations = Random.Range(dungeonData.iterationMin, dungeonData.iterationMax); for(int i = 0; i < iterations; i++) { foreach(DungeonCrawler dungeonCrawler in dungeonCrawlers) { Vector2Int newPos = dungeonCrawler.Move(directionMovementMap); positionsVisited.Add(newPos); } } return positionsVisited; } } RoomController - Here the boss room is spawned Code (CSharp): public class RoomInfo { public string name; public int X; public int Y; } public class RoomController : MonoBehaviour { public static RoomController instance; string currentWorldName = "Basement"; RoomInfo currentLoadRoomData; Room currRoom; Queue<RoomInfo> loadRoomQueue = new Queue<RoomInfo>(); public List<Room> loadedRooms = new List<Room>(); bool isLoadingRoom = false; bool spawnedBossRoom = false; bool updatedRooms = false; ... IEnumerator SpawnBossRoom() { spawnedBossRoom = true; yield return new WaitForSeconds(0.5f); if(loadRoomQueue.Count == 0) { Room bossRoom = loadedRooms[loadedRooms.Count - 1]; GameObject go = new GameObject(); Room tempRoom = go.AddComponent<Room>(); Destroy(bossRoom.gameObject); var roomToRemove = loadedRooms.Single(r => r.X == tempRoom.X && r.Y == tempRoom.Y); loadedRooms.Remove(roomToRemove); LoadRoom("End", tempRoom.X, tempRoom.Y); } } public void LoadRoom( string name, int x, int y) { if(DoesRoomExist(x, y) == true) { return; } RoomInfo newRoomData = new RoomInfo(); newRoomData.name = name; newRoomData.X = x; newRoomData.Y = y; loadRoomQueue.Enqueue(newRoomData); } ... Is someone able to help me?
Hi there! I know it's way too late but in case anyone else has this problem: I had the same issue and at one point I realised that the end room spawned at the right place and only the picture at the start room. You could check if the picture is in the room or outside in the scene. That was my issue. Other than that, the guy has a script somewhere where he fixes the double-spawning problem. Hope that helped!