Operator '==' is ambiguous on operands of type 'Vector3' and 'Vector2'

public Transform target;
public Transform target2;
public GameObject plat;// the target position
public float speed; // speed - units per second (gives you control of how fast the object will move in the inspector)
public bool moveObj; // a public bool that allows you to toggle this script on and off in the inspector
Vector2 returnpos = new Vector2(0f, 4.83f);

    // Update is called once per frame
    void Update()
    {
        if (moveObj == true)
        {
            float step = speed * Time.deltaTime; // step size = speed * frame time
            transform.position = Vector3.MoveTowards(transform.position, target.position, step); // moves position a step closer to the target position
        }

        if (moveObj == false)
        {
            float step = speed * Time.deltaTime; // step size = speed * frame time
            transform.position = Vector3.MoveTowards(transform.position, target2.position, step); // moves position a step closer to the target position
        }

        if (plat.transform.position == returnpos)
        {
            moveObj = false;
        }
    }

btw error occurs line 29

Not sure where line 29 is, as you don’t show the whole page. But I can definitely see where your problem is though:

if (plat.transform.position == returnpos)
         {
             moveObj = false;
         }

your returnpos is a Vector2, and you are trying to calculate a Vector3 against it. You can only calculate a Vector3 by another Vector3, unless you learn Quaternion syntax’s, but they’re basically a Vector4. Maybe you meant to type:

Vector3 returnpos = new Vector3(0f, 4.83f, 0f);

And your error should go away :slight_smile: