Let’s create a program that grabs gameobjects and applies a function to them.

First begin by setting the gameobjects to a custom tag — in this case, player.

Next, we want to create a return function. In this, we want to get all the gameobjects in this array and create a new function called getallplayers().

With that array created, we now want to find all objects with a tag in the scene. So we will search for every object with the tag Player using findgameobjectswithtag.

Then, we need to return all of the players that we gathered and apply that into players.

This allows us to now store all of our objects in our scene to the array of player. Great way to search enemies in scene quickly. We can then do the color adjustment by doing a foreach loop through all of the enemies.