I’m trying to use GetComponent to get the boolean values from another script.
The variables are in the script “RoomVars”, which exists in an array of prefab GameObjects called roomLayout[,]. I’m not fantastic with Unity, but figuring it out slowly!
Code so far:
bool doorway = false;
RoomVars checkDoors;
checkDoors = GetComponent<roomLayout[randomRoomX,randomRoomY].RoomVars>();
randomDirection = Random.Range (0,4);
if (randomDirection == 0){
if (checkDoors.exitNorth == true)
doorway = true;
if (doorway == true && roomLayout[randomRoomX,randomRoomY-1] == RoomPrefabs[0]){
//Instantiate the room.
}
}
The basic idea is that we can create new rooms to add to the game’s dungeon generator, then throw the “RoomVars” script into the room object and simply check off whether this room has an exit to the north, one to the east, etc. Then the code will account for what those variables tell it and adjust where the rooms are placed accordingly!
If I’m not giving you guys enough information let me know, I haven’t used GetComponent in this way before.