This entry is part of a series of tips I am creating as I make my game.
You can use Bolt for free by downloading it from the Asset Store.
Details
What we need: A list of all game objects on a character with a specific tag.
Input: The character game object that has the weapons you are looking for. These weapons should have a specific tag attached (such as ‘Attack’).
Output: A list of game objects attached to that character with the specified tag (such as ‘Attack’).
How this saves you time: No more manually filling lists; just attach this script anywhere on the character and then any weapon you attach to the character is automatically found so long as it has the specified tag.
Summary: Let’s say that you’ve applied the ‘Attack’ tag to game objects (Lets call these ‘Weapons’) in your scene that are attached to a specific character. You have the Axe weapon, the Sword weapon, and the Spear weapon. If your scene contained many characters, you would want a method for each character to identify which weapons are theirs.
Output

How to Implement

- Find all game objects with the specified tag. (This searches the entire scene)
- For each object found, check to see if the root transform of the found object matches the root transform of the object this script is attached to.
- If they match, add the object to a Game Object List.