
[ad_1]
I’m not a lot of an professional, tried to search for for options however I by no means discovered any that I might use.
I’ve a mother or father object, and I need to change it is baby objects randomly. This is the hierarcy:
I need to change each the “Roof” and the “Building” sprites randomly.
This is how my code appears to be like like proper now:
public Sprite[] sprites;
void Update()
{
RandomizeSprites();
}
public void RandomizeSprites()
{
random = Random.Range(0, sprites.Length);
GetComponentInChildren<SpriteRenderer>().sprite = sprites[random];
}
This at present solely works for the primary baby object.
Can anybody assist me find out how to do it for each?
Thank you prematurely!
[ad_2]