- Home /
Rooms being spawned in the wrong places? (Random Generation)
Okay, it's kind of hard to explain what my problem is, but I'll give it a go. I know how much it sucks to read through a question that makes no sense.
So, first of all, I am using the asset DunGen for my game: (In case you're curious: https://www.assetstore.unity3d.com/en/#!/content/15682)
To make it work, you build rooms with doorways in them (the doorways are not prefabs, they are just objects with a script attached to them contained in the prefab, making me think the problem is not nested prefabs). You then make these rooms into prefabs, and DunGen pieces the different room prefabs together, connecting them through the doorways. If you're still curious, you can see how it works in the documentation here: http://www.aegongames.com/blog/wp-content/uploads/DunGen_Readme.pdf
So here's my problem: When I build a room and make a prefab out of it, then I add that room to the dungeon maker, it works just fine! It build a dungeon just fine with that room. But if I make any sort of change to that room and then push "Apply" to the prefab, suddenly DunGen starts screwing up the placement of the rooms, badly. I don't even have to make a change to the prefab, it just happens if I push the "Apply" button. I'll show you the difference:
This is a dungeon built out of one room:
This is a dungeon built out of the same room, no changes made to it, all I did was place the prefab in the scene, push the "Apply" button, then delete it from the scene again:
It suddenly gets the placement completely wrong. Though according to the placement of the doors, the rooms still seem to think they are connected to each other. Even though obviously, they aren't.
I am baffled as to what could be causing this problem, and hopefully this question makes enough sense. If anybody could offer help to figuring out what is causing this, I would be very grateful. Thank you in advance for any help you guys offer!
It looks like your generator is using the instantiated object's position information (which should generally be regarded as bad data), so when you apply it uses the new world position and gets offset weird.
I... love... your... face... You just solved my problem that I've been struggling with for 2 days! You were completely right! All I had to do was move the room to position 0, 0, 0, then click apply again! (Where previously, I had it at a totally random position when clicking the apply button). Thank you so much. If you could convert your comment to an answer, I'd be glad to accept it.