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.