I have a randomized list of colors set up. There are 4 colors in the list.
Every time the "ball" gameObject collides with this gameObject, the color randomizes. I just want to set the tag of the gameObject to whatever color it randomizes to. In order to do that, I first need to check what the randomizer chose in the list and I'm not sure how to do that.
This video shows the randomize list code I used in full: https://www.youtube.com/watch?v=8Xx6ghSk668
void OnTriggerExit2D(Collider2D col)
{
if (col.gameObject.name == "ball")
{
Color c = TintColors[Random.Range(0, TintColors.Count)];
//scoretext++ (< haven't set this up yet. Ignore this)
GetComponent<Renderer>().material.color = c;
//When you score, the color randomizes again
//Not sure what to do here v
if (TintColors(1))
//Not sure what to do here ^
//If the randomizer chose blue (1 being the
// first element in the list)
//So I can change the gameoject tag to "blue"
{
transform.gameObject.tag = "blue";
}
}
}
Aucun commentaire:
Enregistrer un commentaire