Calculating distance, just with position?

Hey guys,

I was asking because I need to calculate the distance between two different objects, if I need to have to take the position? Does he just uses the position or also the size?

For example:
I have created an empty gameObject called Biome. This objects scale is: 32, (not relevant), 128.

And then I’m using:
float distance = Vector3.Distance(Camera.main.position, Biome.position);

But does he goes from the middle point of that object or is he also using the scale? Because the object Biome is 32x128 and position ist just in the middle of that object, or am I wrong?

Kindest Regards,
Matt

The gameobject’s position would be Biome.transform.position

position is in world coordinates and goes to the point which is the x,y,z coordinates in the transform. The rendering of an attached mesh or texture may be offset from that coordinate, but the distance you are computing will be in world-space to that transform’s position. Scale doesn’t matter. Now you may have local scales in the hierarchy which affect the final world position, but because you are accessing ‘position’ you get the world coordinate after scales and rotations have been applied. Easy.