var diff = objB.transform.position - objA.transform.position;
var distance = diff.magnitude;
// or just
distance = (objB.transform.position - objA.transform.position).magnitude;
If you create a cube in Unity then that cube sides are 1 unit long. Thus you can scale it and the lengths will always match the scale in units. Very useful the get a feeling for how big/small objects are.
Using Vector3.Distance does the exact same thing as the magnitude method behind the scenes, so there’s no difference; it’s just easier to remember. One reason to use the latter, though, would be to substitute “.sqrMagnitude” for “.magnitude”, which is quite a bit faster since it doesn’t have to do a square root. This gives you the square distance instead, of course, but that can still be useful in many cases. So if it’s something you’re checking every frame, try to use the sqrMagnitude method where possible instead of Vector3.Distance.
Another thing to consider is that when you subtract one vector from another, you get a new vector that can be added back to the second vector to arrive at the first (I hope I didn’t flip the order of that, I haven’t had coffee yet and my thinking is really cloudy).
Why is this important? Well, the magnitude of this second vector is the distance between them, and this vector also contains directional information between them, so if you will ultimately be doing anything with that information (whether firing a projectile or determining the degree of alignment or moving the character or whatever) simple subtraction can simplify things.
Also, Eric’s advice is good – it isn’t a major optimization for things that aren’t happening in a loop, but getting in the habit of comparing sqrMagnitude to a value times itself (a square distance limit), when appropriate, is probably a good thing.