Ambiguous call between vector 2 and vector3

I want to do a little game in 2D, when I will click and drag an object with collider and rigidbody2D he will follow the mouse.
So this is my script :

They say I got this error:

Assets/MouseManager.cs(17,43): error CS0121: The call is ambiguous between the following methods or properties: UnityEngine.Vector2.operator +(UnityEngine.Vector2, UnityEngine.Vector2)' and UnityEngine.Vector3.operator +(UnityEngine.Vector3, UnityEngine.Vector3)’

So wath is bad in my script ?

Thank you to answer me :slight_smile:

I think it’s probably line 17 in your screenshot. You’re adding the result of ScreenToWorldPoint which returns a Vector3, and offset which is Vector2. The + operator can’t really figure out for sure which type it should work with so it throws the error.

Since you know you’re doing Vector2, you can typecast the result of ScreenToWorldPoint to a Vector2.

Vector2 curPosition = 
    (Vector2)Camera.main.ScreenToWorldPoint(curScreenPoint) + offset;

But that raises the question, shouldn’t curPosition be a Vector3 since you’re dealing with a world point? It depends on what you’re trying to do, but something to consider.