4. Map construction: ProBuilder plugin

ProBuilder plugin

Building the Spawn Base

The final state could look something like this:

Upstairs

Upstairs visibility

using UnityEngine;

public class FloorVisibility : MonoBehaviour
{
    public GameObject player; // Reference to the player GameObject
    public GameObject floor1; // Reference to the parent GameObject representing the upper floor

    void Update()
    {
        if (IsPlayerOnFloor1())
            floor1.SetActive(true);
        else
            floor1.SetActive(false);
    }

    bool IsPlayerOnFloor1()
    {
        // Check if the player's Y position is greater than the upper floor's Y position
        return player.transform.position.y > 10;
    }
}
using UnityEngine;

public class FloorVisibility : MonoBehaviour
{
    public GameObject player; // Reference to the player GameObject
    public GameObject floor1; // Reference to the parent GameObject representing the upper floor
    public GameObject floor1Trigger; // Reference to the parent GameObject containing all the triggers for the upper floor

    void Update()
    {
        if (IsPlayerOnFloor1())
            floor1.SetActive(true);
        else
            floor1.SetActive(false);
    }

    bool IsPlayerOnFloor1()
    {
        // Get all colliders under the floor1Trigger GameObject
        Collider[] colliders = floor1Trigger.GetComponentsInChildren<Collider>();

        // Check if player is inside of any of the upper floor colliders
        foreach (Collider collider in colliders)
        {
            if (collider.bounds.Contains(player.transform.position))
                return true;
        }
        return false;
    }
}
using UnityEngine;

public class FloorVisibility : MonoBehaviour
{
    public GameObject player; // Reference to the player GameObject
    public GameObject floor1; // Reference to the parent GameObject representing the upper floor
    public GameObject floor1Trigger; // Reference to the parent GameObject containing all the triggers for the upper floor

    void Update()
    {
        if (IsPlayerOnFloor1())
            SetFloorVisibility(floor1, true);
        else
            SetFloorVisibility(floor1, false);
    }

    bool IsPlayerOnFloor1()
    {
        // Get all colliders under the floor1Trigger GameObject
        Collider[] colliders = floor1Trigger.GetComponentsInChildren<Collider>();

        // Check if player is inside of any of the upper floor colliders
        foreach (Collider collider in colliders)
        {
            if (collider.bounds.Contains(player.transform.position))
                return true;
        }
        return false;
    }

    void SetFloorVisibility(GameObject floor, bool visible)
    {
        // Get all renderers in the floor object
        Renderer[] renderers = floor.GetComponentsInChildren<Renderer>();

        // Set visibility for each renderer
        foreach (Renderer renderer in renderers)
        {
            renderer.enabled = visible;
        }
    }
}
using UnityEngine;

public class FloorVisibility : MonoBehaviour
{
    public GameObject player; // Reference to the player GameObject
    public GameObject floor1; // Reference to the parent GameObject representing the upper floor
    public GameObject floor1Trigger; // Reference to the parent GameObject containing all the triggers for the upper floor
    public GameObject floor1Tiles; // Reference to the parent GameObject representing the floor tiles

    void Update()
    {
        if (IsPlayerOnFloor1())
        {
            SetFloorVisibility(floor1, true);
            SetFloorLayer(floor1Tiles, "Ground");
        }
        else
        {
            SetFloorVisibility(floor1, false);
            SetFloorLayer(floor1Tiles, "Default");
        }
    }

    bool IsPlayerOnFloor1()
    {
        // Get all colliders under the floor1Trigger GameObject
        Collider[] colliders = floor1Trigger.GetComponentsInChildren<Collider>();

        // Check if any of the player's colliders are overlapping with any of the upper floor colliders
        foreach (Collider collider in colliders)
        {
            if (collider.bounds.Contains(player.transform.position))
                return true;
        }
        return false;
    }

    void SetFloorVisibility(GameObject floor, bool visible)
    {
        // Get all renderers in the floor object
        Renderer[] renderers = floor.GetComponentsInChildren<Renderer>();

        // Set visibility for each renderer
        foreach (Renderer renderer in renderers)
        {
            renderer.enabled = visible;
        }
    }

    // Function to change the layer of all child objects under a specified parent GameObject
    public void SetFloorLayer(GameObject floorTiles, string layerName)
    {
        // Find the layer index based on the layer name
        int layerIndex = LayerMask.NameToLayer(layerName);

        // Iterate through all child objects of the specified parent GameObject
        foreach (Transform child in floorTiles.transform)
        {
            // Change the layer of each child object to the specified layer
            child.gameObject.layer = layerIndex;
        }
    }
}

< ^ >