- Home /
Remove objects from list when they are out of range.
Hi!
I add items to a list when they are in range of my exploding object.
private List<GameObject> ReachableObjects = new List<GameObject>();
SphereCollider checkObjects = objectChecker.GetComponent<SphereCollider>();
public void OnTriggerEnter(Collider objectList){
ReachableObjects.Add(objectList.gameObject);
I need to remove the objects from the list when the exploding object is out of range. As it is now all items that have been close to the exploding game object will be destroyed when the explosion occurs. I only want the objects that are within the collider to be destroyed so I need to remove the others from the list when they are out of range.
How do I do this?
Thank you very much!
Comment
Your answer
![](https://koobas.hobune.stream/wayback/20220612113802im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Distribute terrain in zones 3 Answers
How To Properly Return An Object If Within Distance Range? 1 Answer
GameObject1 move away when GameObject2 gets close 1 Answer
List.Contains Problem 1 Answer