If statement help. (positioning)

What ways are there to make a if statement that ask the question “if object1 position equals object2 position do this if else do that”? I am more specifically having troubles with my code:

#pragma strict

var Target : Transform;
var Distance = -10;
var Lift = 1.5;
var script: TriggerCam1;
var parget: Transform;
var speed: float;
var CamChange = 0;
var speedt: float;
var pargett: Transform;
var endcut : Transform;
var cam : Transform;


function Update () 
{
	if (CamChange == 1)
	{
	var step = speed * Time.deltaTime;
	
	transform.position = Vector3.MoveTowards(transform.position, parget.position, step);
	}
	 
	else
		if (CamChange == 2)
				if (cam.position == endcut.position) //I know this doesn't work, but it's to help show what I need.
			{
				CamChange == 0;
			}
			else
		{
			var stept = speedt * Time.deltaTime;
			
			transform.position = Vector3.MoveTowards(transform.position, pargett.position, stept);
		}
		else
		{
		transform.position = Target.position + Vector3(0, Lift, Distance);
		transform.LookAt(Target);
		}
}

under CamChange == 2 it has the if statement. that is where i need help. I dont know how to make that type of if statement.

First off, always use brackets and proper formatting if you want your code to be readable and make sense. It becomes much harder to read and debug without, even to a veteran programmer. See below for an example:

#pragma strict
 
 var Target : Transform;
 var Distance = -10;
 var Lift = 1.5;
 var script: TriggerCam1;
 var parget: Transform;
 var speed: float;
 var CamChange = 0;
 var speedt: float;
 var pargett: Transform;
 var endcut : Transform;
 var cam : Transform;
 
 
 function Update () 
 {
     if (CamChange == 1)
     {
         var step = speed * Time.deltaTime;
     
         transform.position = Vector3.MoveTowards(transform.position, parget.position, step);
     }
     else if (CamChange == 2)
     {
         if (cam.position == endcut.position) //I know this doesn't work, but it's to help show what I need.
         {
             CamChange == 0;
         }
         else
         {
             var stept = speedt * Time.deltaTime;
             
             transform.position = Vector3.MoveTowards(transform.position, pargett.position, stept);
         }
     }
     else
     {
         transform.position = Target.position + Vector3(0, Lift, Distance);
         transform.LookAt(Target);
     }
 }

That being said, your code is technically correct. However, it likely will not give the result you are looking for. The reason is that the positions are floating point numbers. So, given the following Vector3s:

(0, 0, 2.000000000000)
(0, 0, 2.000000000001)

On screen, these would look like they were the exact same, but they are technically not equal.

What you want to do, is check if they are “close enough” to equal. So, you want to try something like:

if((cam.position-endcut.position).magnitude < 0.01f)

However, that code uses “magnitude” which requires a square root to run (Pythagorean equation). So, to optimize it, you usually square both sides of the equation as such:

if((cam.position-endcut.position).sqrMagnitude < 0.01f * 0.01f)