Algorithms stops when there are 2 rooms of the same class
agrizzli opened this issue · comments
e.g. here to the extreme left and right the Room_Example3:
https://www.dropbox.com/s/pxqf0mwoa4rzmbs/Screenshot%20from%202020-11-28%2014-11-59.png?dl=0
Then one of these rooms have Door objects correctly linked (see at bottom).
https://www.dropbox.com/s/3tbd8rd4p1vc50e/Screenshot%20from%202020-11-28%2014-13-45.png?dl=0
Possibly the error happens in ComputeNewDoorsPos
. At least there is a warning about it.
You are trying to create a MonoBehaviour using the 'new' keyword. This is not allowed. MonoBehaviours can only be added using AddComponent(). Alternatively, your script can inherit from ScriptableObject or no base class at all UnityEngine.MonoBehaviour:.ctor() Door:.ctor(Vector2Int, Vector2Int) (at Assets/Scripts/PCG/Door.cs:12) Grid:ComputeNewDoorsPos(Room, Door, Door, Single) (at Assets/Scripts/PCG/Grid.cs:97) Grid:CheckRoomSpawnValidity(Room, Door, Door) (at Assets/Scripts/PCG/Grid.cs:42) Generator:Generate(Vector2Int, Int32) (at Assets/Scripts/PCG/Generator.cs:64) Generator:Start() (at Assets/Scripts/PCG/Generator.cs:25)
Some problems related with this:
It is possible that we are missing pointer logic related to this. When spawning a prefab, do we have the pointers to the Instantiated room GO or to an uninstantiated GO included in the prefab?
In which case, room instantiation should return the room object, and reference it whenever needed. Similarly, it may be necessary to re-link the door GOs in room instantiation, since spawning a room spawns door children, whose properties (inner outer position) require to be set to the absolute value (and if this is done in the prefab's GO, it will most definitely destroy the PCG logic).
Additionally, we located that there was no openDoor removal yet. This caused many used doors to be retried, drastically reducing the number of actually spawned rooms since the trials failed so many times.