The call is ambiguous between the following methods or properties: `UnityEngine.Vector3.operator ==(UnityEngine.Vector3, UnityEngine.Vector3)' and `UnityEngine.Vector2.operator ==(UnityEngine.Vector2, UnityEngine.Vector2)'

I am trying to make my first mobile game with unity. In this game, you click an object and it disappears. Here is my code:

using UnityEngine;
using System.Collections;

public class Touch : MonoBehaviour {

	public GameObject g;

	// Use this for initialization
	void Start () {
	
	}
	
	// Update is called once per frame
	void Update () {

		UnityEngine.Touch myTouch = Input.GetTouch (0);


		if (myTouch.position == g.transform.position)
		{
			Destroy (g);
		}
	}
}

however a get an error:

Assets/Scripts/Touch.cs(19,29): error CS0121: The call is ambiguous between the following methods or properties: UnityEngine.Vector3.operator ==(UnityEngine.Vector3, UnityEngine.Vector3)’ and UnityEngine.Vector2.operator ==(UnityEngine.Vector2, UnityEngine.Vector2)'.

What am I doing wrong?

you’re trying to compare a Vector2 (touch.position) with a Vector3 (transform.position)

since the components of each Vector is a float, you should use something like Mathf.Approximately() too…