Question by 
               tenkyofmadness · May 10, 2020 at 05:15 AM · 
                objectsobject pooldeactivate  
              
 
              Object Pooling I can't figure out how to deactivate a object
I'm trying to make a endless 2D runner and I can't figure out how to deactivate a object when it passes a certain position on X axis.
 public Transform generationPoint;
 public Transform destructionPoint;
 private float distanceBetween;
 public float minObstacleSpacing;
 public float maxObstacleSpacing;
 private float yPosition;
 public float minObstacleY;
 public float maxObstacleY;
 // Update is called once per frame
 void Update()
 {
     
     if (transform.position.x < generationPoint.position.x)
     {
         GameObject prefab = ObjectPooler.SharedInstance.GetPooledObject();
         //Razmaku izmedu prepreka
         distanceBetween = Random.Range(minObstacleSpacing, maxObstacleSpacing);
         //Pozijicija prepreke na Y osi
         yPosition = Random.Range(minObstacleY, maxObstacleY);
         //Postavljanje pozicije nove prepreke
         transform.position = new Vector3(transform.position.x + distanceBetween, transform.position.y + yPosition, 0f);
         //Stvaranje prepreke
         if (prefab != null)
         {
             prefab.transform.position = transform.position;
             prefab.SetActive(true);
         }
         if (prefab.transform.position.x < destructionPoint.position.x)
         {
             prefab.SetActive(false);
         }
     }
}
               Comment
              
 
               
              Your answer
 
 
              koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                