'Unity Engine set Active random Child Object
I want to make an Apocalypse Game and have a Zombie Model with different Materials as Children, I want to randomly activate them, wehn the Zombie spawns (in void start)
I have tried different options, like this:
public class RandomSkin : MonoBehaviour
{
public GameObject Zombie;
void Start()
{
int randomChildIdx = Random.Range(0, Zombie.transform.childCount);
Transform randomChild = Zombie.transform.GetChild(randomChildIdx);
}
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
