I’ve looked around at all the forums I can regarding this and I’m still stumped.
My goal is to instantiate a field (with a bunch of objects including 3 player spawn tiles), click on a gui button and have a character spawn on P1T (if its available), then spawn two other characters on the other two tiles.
I’ve got quite a few levels that all sit as prefabs in the same scene. Its important that the objects are instantiated because of how the level progression works. However when I instantiate one of the fields the child objects lose their tags. And when I tried to create a script on the tiles to have them change their own tags when they Awake, the scripts aren’t even components once the parent object is instantiated.
Does anybody know how I could assign them tags after they’re instantiated or have the tags stay?
And once I’m able to spawn a character is there any way I could do a simple- if tag P1 exists on the hierarchy check for P2?
public class OnCharButtonClick : MonoBehaviour {
public GameObject PlayerPrefab;
private GameObject P1Tile;
public void ChooseChar(int level)
{
// button turns grey
// button becomes disabled
// Instantiate PlayerPrefab
// Check if tag P1
// if yes check if P2
// if yes check if P3
// if yes debug too many characters
// if no change PlayerPrefab tag to P3
// -Close Panel
// if no change to P2
// if no change to P1
P1Tile = GameObject.FindWithTag("P1T");
Instantiate (PlayerPrefab,P1Tile.transform.position,Quaternion.identity);
}
}