Instantiate object a minimum distance from another gameobject

In this game I am instantiating multiple object (turrets) and I want them to have a minimum distance apart. I tried “if ((player.transform.position - turret.transform.position) > 5 )” but I am getting errors.

The error you get is because you can’t test for relative size between a Vector3 and a float/int.

A Vector3, A, minus a Vector3, B, yields a third Vector3, C. C is a ray which points from B to A, with a magnitude equal to the distance between A and B.

In rough math/pseudocode:

Vector3 A = some point
Vector3 B = some other point

Vector3 C = A - B

B + C = A
C.magnitude = Vector3.Distance (A, B)

If you just need the distance between to Vector3’s, you can use Vector3.Distance(), or get the magnitude of the result of your subtraction operation in the example you posted.