1. Hello, I was wondering if it was possible to the height of an already placed foundation. I also want to know if it would be possible to work out the maximum height at which that foundation can be placed at its current location.

    Sorry for the stupid question.
     
  2. Calytic

    Calytic Community Admin Community Mod

    This is not a stupid question.

    Code:
    public static float GetGroundY(BuildingBlock block)
    {
        RaycastHit hitinfo;
        position = block.transform.position;
        if (Physics.Raycast(position, new Vector3(0f, -1f, 0f), out hitinfo, 100f, UnityEngine.LayerMask.GetMask(new string[] { "Terrain" })))
        {
            return hitinfo.point.y;
        }
        return position.y;
    }
    You can use this function, or something very close to this function for both questions.
    Code:
    float currentHeight = GetGroundY(block);
    float maxHeight = GetGroundY(block) + FoundationHeight
    You'll have to figure out whatever the foundation height is by default. I don't know how to get that programmatically off-hand. I imagine a little trial and error could probably reveal it's somewhere between 2 and 4.