Why my sprite Z position is changing when i use Vector2 to change it's x & y positions?

For some reason when i’m trying to change the position of the sprite like this:
Vector2 newPos = new Vector2(12f, transform.position.y);
transform.position = newPos;
it changes the Z position to 0.
Is it a bug in unity or they changed the way the vector2 works ?
More information:
There’s only a Polygon collider 2d component on the object.(No Rigidbody included)
I’m trying to think about a way to fix it , obviously i could just use vector3 and force it to stay at the Z position i want , but there’s no reason i should do so , because it’s a problem in the unity.
Hope to get any help , trying to fix it for couple days :frowning:

I think that when you cast Vector2 to Vector3 in Unity it just adds the Z-axis with the value of zero.


I ran this line of code: `Debug.Log((Vector3)new Vector2(1, 0.5f));`

and the output was (1.0, 0.5, 0.0) which implies that unity probably (and unfortunatly for you) does do that.