Instantiating with a chance to be rotated.

Hello, trying to make a simple flappy bird style game but somehow am struggling a lot.
I want to code walls to appear with a 1/2 chance of being at a 180 degree rotation to the original sprite ( so that there are both up and down walls.)
I’ve got this code so far.

void Start()
{
    StartCoroutine(CreatePrefab());
}

IEnumerator CreatePrefab()
{
    for (int i = 0; i < 10; i++)
    {
        yield return new WaitForSeconds(SecondsBetweenWalls);
        int ChooseSprite = Random.Range(1, 2);
        if (ChooseSprite == 1)
        {
            float instX = instantiateObjectHere.transform.position.x;
            float instY = Random.Range((float)-5.2, (float)-1.2);
            newInstance = Instantiate(Wall, new Vector2(instX, instY), Quaternion.identity);
        }
        else
        {
            float instX = instantiateObjectHere.transform.position.x;
            float instY = Random.Range((float)-5.2, (float)-1.2);
            newInstance = Instantiate(Wall, new Vector2(instX, instY), Quaternion.Euler(new Vector3(0, 180, 0)));
        }   

    }
}

It does spawn the walls at random y levels as supposed to, but the rotation part doesn’t work
It doesn’t return any error so any help would be appreciated.
Sorry if this is really simple, this is my first go at unity.
Thanks in advance.


Haya bud - instead of using int ChooseSprite = Random.Range(1, 2); try int ChooseSprite = Random.Range(0, 2); - Unity uses inclusive ranges so that means Random.Range works more like
Random.Range(Min, Max - 1);


Also i think you need to do Quaternion.Euler(0, 0, 180) as 1. Quaternion.Euler doesn’t take Vector3 as an input iirc and 2. unity 2d works on the Z axis (that is if your using 2d of course) like Llama said