any small pushes how should I approach this will be helpful thanks in advance
problem is not within the code thing is I wanted to go not to destroy and istantiate a new GO at all
but as soon as I moved to figureing what kind of GO are actually falsed I figured out I’m already destroying a GO so doing all complex for nothing
problem is the first one might never get falsed and the last one will or the other way around
this are not bullets but bricks or what ever that are false ONLY when player picks them up
yes this works smoothly and all but I think it’s even less effective than just destroying a GO and instantiating new one
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
// TRAINING PURPOSES ONLY
public class Pooling : MonoBehaviour {
public GameObject prefab ;
public List<GameObject> ActiveCopy ;
public List<GameObject> DeactiveCopy ;
public float time = 0;
public float time1 = 0;
public float timeremaining = 0.1f ;
public bool NewOne = false ;
void Update (){
if (! NewOne){
time = Time.time ;
NewOne = true ;
}
time1 = Time.time ;
if ((time1 - time) > timeremaining){
ActiveCopy.Add(prefab);
ActiveCopy[ActiveCopy.Count-1] = Instantiate( ActiveCopy[ActiveCopy.Count-1] ) as GameObject;
ActiveCopy[ActiveCopy.Count-1].transform.position = transform.position ;
ActiveCopy[ActiveCopy.Count-1].transform.parent = transform ;
Deactivate(ActiveCopy.Count-1);
NewOne = false ;
}
}
void Deactivate (int Count) {
ActiveCopy[Count].SetActive(false) ;
DeactiveCopy.Add(ActiveCopy[Count]) ;
ActiveCopy.Remove(ActiveCopy[Count]) ;
}
}
I didn’t create with
public GameObject[] Copy
because every time I do than
Copy = new GameObject[(IncreasedNumber)]
all GO are simply deleted within Copy and Copy does not contain them any longer while they exist in scene and I can’t track them
I thinked a bit more and heard some times about taggs I don’t even know how does tagging work
all I want is find the object that’s false it doesn’t matter first false or last false one but defenally I don’t want to pick up the true one
they will not get false over time but randomely by player when player picks it up