[Solved] How to LINQ to ArrayList all the Transform within a Range?

Hello Devs,

I am having a Player falling down and I wish to deactivate all the Transforms which are above the player. I am not trying to do this every frame but after a certain checkpoint.

Hence I have this idea.

  1. LINQ all the transforms with a certain tag above the player’s height
  2. Store the Transform into a ArrayList
  3. foreach the ArrayList to deactivate the required.

If I am not clear or have not provided with enough information, kindly let me know.

Your help as always is much appreciated.



So, I found the solution to it. I had to use two ArrayList. I assume that there is a much easier solution to it. But for the moment this works.

	public List<Transform> NPCList, NPCListCopy;

// Module to be called whenever needed. 
NPCList = GameObject.FindGameObjectsWithTag("NPC")
  				  .Select(go => go.transform)
		NPCListCopy =	(from t in NPCList
					where t.position.y > 600 
					select t)


P.S. : If you guys find a smarter and more simpler solution, please let me know.