Hi,everyone,what im trying to do is to have an object move back if 2 objects get close to each other and i have to do that with vectors but im getting an error. That error says Operator <= cannot be used with a left hand side of type 'UnityEngine.Vector3' and a right hand side of type 'UnityEngine.Vector3'

I seriously got no idea what to use so any idea would be really appreciated Thank You Very Much

function Update()
{
Player1= GameObject.FindWithTag("Player1");
Player2= GameObject.FindWithTag("Player2");
AllPlayers= Player1.transform.position + Player2.transform.position;
transform.position = AllPlayers/2;
if(AllPlayers <= Vector3(100,0,0))
{
transform.position.x=AllPlayers.x/2;
transform.position.y= AllPlayers.y*2;
transform.position.z=AllPlayers.z/2;
}
}

In case i wasnt really specific with my problem tell me plz i will try to explain it more

tried to do it this way and the other with alot of other things but seems like Transform wont let me do that it says the best overload for the method Distance is not compatible with the argument list UnityEngine.Transform The Problem is still in the same spot and this is how it looks like

var point1 : Transform;
var point2 : Transform;
var distance : float = 10;
function Update () {
if(Vector3.Distance(point1,point2)<=distance){
DoSomthing();
}
}

function DoSomthing () {
/*transform.position.x=(point1.transform.position.x + point2.transform.position.x)/2;
transform.position.y= (point1.transform.position.y + point2.transform.position.y)*2;
transform.position.z=(point1.transform.position.z + point2.transform.position.z)/2;*/
transform.position =(point1.transform.position+ point2.transform.position)/2;
}

you have to use Vector3.Distance(); for stuff like that EG :

var point1 : Transform;
var point2 : Transform;
var distance : float = 10;
function Update () {
if(Vector3.Distance(point1.position,point2.position)<=distance){
DoSomthing();
}
}

function DoSomthing () {
//do stuff here
}

hope this helps

You can't compare Vector3's that way as what does it actually mean for one to be less than the other?

What you actually want to do is compare distances

eg. Vector3.Distance(obj1, obj2) <= someDistance