Hey there! I’m looking for some help concerning my problem here. Well, from one script I instantiate object that I track in this script as a array of GameObjects with FindGameObjectsWithTag. It is working as a charm, but I just cant get the Vector3 of those GameObjects and store them in their own array.
So here is the script in question:
public GameObject holeBlockPrefab;
public GameObject[] holeBlocks;
public Vector3[] holeBlocksPositions;
public int holeBlocksCount;
public int loadHoleBlockCount;
void Awake() {
if(PlayerPrefs.GetString("LoadType") != "NewGame") {
loadHoleBlockCount = PlayerPrefs.GetInt("HoleBlocksCount");
if(loadHoleBlockCount != 0) {
SpawnObjectOnLoadSaveGame(holeBlockPrefab);
}
}
}
void Update() {
holeBlocks = GameObject.FindGameObjectsWithTag("Hole");
holeBlocksCount = holeBlocks.Length;
if(Input.GetKeyDown(KeyCode.F5)) {
PlayerPrefs.SetInt ("HoleBlocksCount", holeBlocksCount);
Debug.Log("Saved hole blocks count.");
}
}