If i have some vector 3 position in the world and i have some collider (box, sphere…) in the world as well, how do i find out, which position in this collider is the most far from my vector 3 position?
So basically reversed ClosestPointOnBounds, ( as in something like FarthestPointOnBounds). Thanks
If the collider is a primitive you can use the properties of the primitive to ‘project’ the position across. Spheres will be easiest, but it will work with cubes or capsules as well.
If you are working with a complex mesh collider you are stuck iterating through vertices of the mesh and doing distance checking on each one.
Edit: Just realised you are working with bounds. This makes it pretty simple. Just check the corners of the bounding box to determine which point is furthest away. Fun fact, with cubes it will always be one of the corners on the opposite face that is furthest away.
Thanks guys, it works. But i noticed one buglike thing. If i place sphere on the vert coordinates to actually see them visually, the get placed exactly at the collider box vertices if the game object is placed with zero rotation. But if the object is rotated then the verts are in incorrect position it seems.