Get the lowest point of an object

public static Vector3 PutAnchor(GameObject gameObject)
    {
        float currLowestY = Mathf.Infinity;
    
        Vector3 lowestBounds = default;

        foreach (Renderer renderer in gameObject.GetComponentsInChildren<Renderer>())
        {
            CreateDemoCube(renderer.bounds.min);
            if (renderer.bounds.min.y < currLowestY)
            {
                lowestBounds = renderer.bounds.min;
               currLowestY = renderer.bounds.min.y;
            }
        }

        CreateDemoCube(lowestBounds);

        return lowestBounds;
    }

I’m trying to put a cube on the position of the yellow cross by finding its lowest Y point:
7562578--935710--cubed.png

Renderer.bounds does only the bounds, not the shape being cast.

1 Like

You have to use transform.TransformPoint on every verticy of the cube. This gives you the world space position of each of them and you can then select the lowest one.

See: Find extreme points of rotated gameObjects? (screenshot example) - Questions & Answers - Unity Discussions

1 Like

Hello,

Here is my simple extension:

public static float GetLowestPoint<T>(this Transform origin) where T : Collider =>
    origin.GetComponent<T>().bounds.min.y;

And it can be used this way:

if (frameRate >= 1.0f || transform.GetLowestPoint<BoxCollider>() <= MIN_FORCED_Y)
{
    // do your stuff..
}
2 Likes