- Home /
[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.
LINQ all the transforms with a certain tag above the player's height
Store the Transform into a ArrayList
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.
regards,
Karsnen.
$$anonymous$$arsnen
This may help, here is Linq to SQLite. https://www.kellermansoftware.com/p-47-net-data-access-layer.aspx
Answer by Karsnen_2 · Jan 09, 2013 at 03:18 PM
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.
//Declaration
public List<Transform> NPCList, NPCListCopy;
// Module to be called whenever needed.
NPCList = GameObject.FindGameObjectsWithTag("NPC")
.Select(go => go.transform)
.ToList();
NPCListCopy = (from t in NPCList
where t.position.y > 600
select t)
.ToList();
//EOF
Cheers!!!
P.S. : If you guys find a smarter and more simpler solution, please let me know.