Hello i have a problem with FindGameObjectWithTag
Here are the script:
if (gun == null) {
Debug.Log("gunIsNull");
GameObject.FindGameObjectWithTag("Gun");
}
if (kit == null) {
Debug.Log("kitIsNull");
GameObject.FindGameObjectWithTag("Kit");
}
if (munizion == null) {
Debug.Log("munIsNull");
GameObject.FindGameObjectWithTag("Munizion");
Here is the spawnScript:
random = Random.Range(0, 4);
switch (random) {
case 0:
//Spawn Kit
Instantiate(kit[0], pos[2].position, Quaternion.identity);
//Spawn Munizion
Instantiate(munizion, pos[1].position, Quaternion.identity);
//Spawn Guns
Instantiate(guns[0], pos[0].position, Quaternion.identity);
break;
case 1:
//Spawn Kit
Instantiate(kit[1], pos[2].position, Quaternion.identity);
//Spawn Munizion
Instantiate(munizionSniper, pos[1].position, Quaternion.identity);
//Spawn Guns
Instantiate(guns[1], pos[0].position, Quaternion.identity);
break;
case 2:
//Spawn Kit
Instantiate(kit[0], pos[2].position, Quaternion.identity);
//Spawn Munizion
Instantiate(munizion, pos[1].position, Quaternion.identity);
//Spawn Guns
Instantiate(guns[2], pos[0].position, Quaternion.identity);
break;
case 3:
//Spawn Kit
Instantiate(kit[1], pos[2].position, Quaternion.identity);
//Spawn Munizion
Instantiate(munizionSniper, pos[1].position, Quaternion.identity);
//Spawn Guns
Instantiate(guns[3], pos[0].position, Quaternion.identity);
break;
}
But it doesn’t work. I think because it spawns objects. But I do inside the void Update and can it not find spawned object with a tag?
Thanks