Can place buildings only in the middle

it turns green only in the centre and red around the corners …

if ((point - building.transform.position).sqrMagnitude <= buildingRangeLimit * buildingRangeLimit)
i tried reversing this line by changing the <= to >= and the opposite happened that is I could place buildings around the corner but not in the centre …and no its not coolider issue since I only one collider ob the main building …

public bool CanPlaceBuilding(BoxCollider buildingCollider, Vector3 point)
{
    if (Physics.CheckBox(
                point + buildingCollider.center,
                buildingCollider.size / 2,
                Quaternion.identity,
                buildingBlockLayer))
    {
        
        return false;
    }

    foreach (Buildings building in buildings)
    {
        if ((point - building.transform.position).sqrMagnitude
            <= buildingRangeLimit * buildingRangeLimit)
        {
            return true;
        }
    }

    return false;
}

here is the code



ha found the solution it should have been foreach(builidngs builidng in myBuilding)

1 Like

Good job, and thanks for sharing your solution! :slight_smile:

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms