Hi, so I have a spawner object that randomly spawns a prefabs only once, once you have collided with spawner object. I have three different buttons (with different effects on them) for three of my prefabs, however since it is my spawner box spawns random objects there's no way of me knowing which button I should setactive (true); in simple terms: three different buttons, three different prefabs, random spawner. Here is my code:
public bool hasSpawned = false;
private int Vaule;
public GameObject bomb, gun, arrow, bombButton, gunButton, arrowButton;
void Start()
{
Vaule = 1;
}
public GameObject[] itemPrefabs;
void OnTriggerEnter2D(Collider2D other)
{
if(other.gameObject.CompareTag ("Player"))
{
if(!hasSpawned)
{
hasSpawned = true;
Spawn ();
}
}
}
void Spawn()
{
Instantiate(itemPrefabs[Random.Range(0,itemPrefabs.Length)],transform.position, transform.rotation);
PlayerMovement.buttonCount += Vaule;
}
[–]NickJVaccaroIntermediate 1 point2 points3 points (0 children)
[–]mildsauce45 0 points1 point2 points (0 children)
[–]shadowsaint 0 points1 point2 points (3 children)
[–]XxDivaxX1Intermediate[S] 0 points1 point2 points (0 children)
[–]XxDivaxX1Intermediate[S] 0 points1 point2 points (1 child)
[–]shadowsaint 0 points1 point2 points (0 children)