I’m trying, unsuccessfully, to find a way to easily calculate the distance between two objects’s collider.
In my case I’m trying between two box collider,
BoxCollider boxColStart = start.GetComponent<BoxCollider>();
Vector3 centerBoxStart = boxColStart.ClosestPointOnBounds(end.transform.position);
BoxCollider boxColEnd = end.GetComponent<BoxCollider>();
Vector3 centerBoxEnd = boxColEnd.ClosestPointOnBounds(start.transform.position);
lineRenderer.SetPosition (0, centerBoxStart);
lineRenderer.SetPosition (1, centerBoxEnd);
the code I’m using is wrong and this sketch is the proof:
every suggestion is very welcome
Thanks
Davide