I'm attempting to generate random dungeons using prefabs.
I have it working to where it will pick a random doorway from a list of doorways and spawn a new room. I then have a script on the bounding box to update the room script for when it intersects another room.
The issue that I am currently having is that I'm not entirely sure on how to wait or delay to check and see if the onTriggerEvent
has been called.
I'm currently checking to see if there was a collision, and setting a boolean
variable to true when that happens otherwise it's false. This always results with the variable being false even though there is collision occurring.
Edit:
This is currently how i'm checking to see if a room is valid:
DungeonGenerator.cs:
// This is being ran in a for loop.
if (currentRoom.isValid())
{
// Removed for clarity. This essentially just places a room.
}
RoomValidation.cs:
private void OnTriggerEnter(Collider other)
{
// This is the variable i was talking about.
// Currently it seems like this is always false when i check.
// If it's false then it fails validation.
if (other.tag.equals("Room"))
room.validated.Invoke(false);
}
The isValid() function just returns a validated boolean variable. This doesn't seem to update fast enough for the collision to update. I've looked into Coroutine's and that doesn't seem feasible to implement. Wouldn't that just run outside of the loop and cause the same issue?