Comparing vector 3 locations

if(Input.GetButtonDown(“up”)){

	//transform.position.currentPos.y = transform.position.currentPos.y+1;
	currentPos.y = currentPos.y+1;
	Debug.Log("currentPos"+ currentPos);
	Debug.Log("startPos" +startPos);
	 	if (currentPos.y != StartPos) { 
 		Debug.Log("after currentPos.y!= startPos condional "+currentPos);
		transform.position.y = transform.position.y+1;
			currentPos= this.transform.position;
	}
		else if(currentPos == startPos){
			Debug.Log("yes");
			currentPos= this.transform.position;
		}
		
}

I want to not allow my player to move up ones if the location they are moving to is the location of where startPos is.

Javascript

Is that you want to move the object in grid but it cannot move to its starting position? If so, I had made some modifications based on your script, you may test it out to see whether it can help you or not.

#pragma strict

private var startPos : Vector3;
private var targetPos : Vector3;


function Start ()
{
	// Record the startPos
	startPos = transform.position;
}


function Update() 
{
	// Set targetPos as the transform's current position
	targetPos = transform.position;


	if (Input.GetKeyDown(KeyCode.LeftArrow))
	{
		targetPos.x -= 1;
	}
	else if (Input.GetKeyDown(KeyCode.RightArrow))
	{
		targetPos.x += 1;
	}
	else if (Input.GetKeyDown(KeyCode.UpArrow))
	{
		targetPos.y += 1;
	}
	else if (Input.GetKeyDown(KeyCode.DownArrow))
	{
		targetPos.y -= 1;
	}


	// Set transform at targetPos if it is not startPos
	if (targetPos != startPos)
	{
		transform.position = targetPos;
	}
}