I am not much of an expert, tried to look up for solutions but I never found any that I could use.
I have a parent object, and I want to change it's child objects randomly. This is the hierarcy:
I want to change both the "Roof" and the "Building" sprites randomly. This is how my code looks like right now:
public Sprite[] sprites;
void Update()
{
RandomizeSprites();
}
public void RandomizeSprites()
{
random = Random.Range(0, sprites.Length);
GetComponentInChildren<SpriteRenderer>().sprite = sprites[random];
}
This currently only works for the first child object.
Can anyone help me how to do it for both? Thank you in advance!