Problems with transform and position detection

I dont know how to explain what im trying to do.
So watch this…
m9eb4h

Basically a limit to that list.
I made it work before, but i played with anchors and now its bugged.
When i click play it teleports everything to the wrong position ( first problem )
The limit is not set properly even though the position in the script coresponds to the one in the scene ( second problem )
After i quit play mode the list teleports to -100 ( third problem )

using UnityEngine;

public class Shop : MonoBehaviour
{
    public GameObject contentGetWithCoins;
    Vector3 leftLimit = new Vector3(0, 27.5f, 0);
    Vector3 rightLimit = new Vector3(-175, 27.5f, 0);
    void Update()
    {
        // Swipe Limit ( LEFT , RIGHT )
        if (contentGetWithCoins.transform.position.x > 0)
        {
            contentGetWithCoins.transform.position = leftLimit;
        }
        if (contentGetWithCoins.transform.position.x < -175)
        {
            contentGetWithCoins.transform.position = rightLimit;
        }
    }
}

The script is attached to a game object inside a group of elements named “Misc”, with the position set to 0 0 0. But i dont think it causes that.
I am lost and brain is dead right now. :slight_smile:
Btw sorry if its a stupid mistake is my 2nd week in unity.

One potential source of confusion is that if your camera is looking +Z (the default way Unity is set up), then your leftLimit is actually to the right of your rightLimit. Negative X goes to the left, positive X goes to the right.

Another potential source of confusion is that your comparison lines (line 11 and 15 above) compare to magic numbers 0 and -175… why not use the actual contents of leftLimit.x and rightLimit.x to compare? That way if you move leftLimit/rightLimit, you don’t have to remember to update the 0 and -175 as well!