- Home /
Array with several gameobjects and their respective script
I'm making a gamecontroller script that handles most of the things like attacks and deaths and so on. In this script I've already made an array that consists of all the gameobjects I want.
private GameObject[] enemies;
enemies = GameObject.FindGameObjectsWithTag ("Enemy");
Every time somethigns interacts with one of these I find their script and use the necesarry method therein. But instead of finding their script everytime I want to store an accesspoint for them and I preferably want it to be in the same array as the gameobject to make it as easy as:
enemies = array[][]
array[0][0] = first gameobject
array[0][1] = first gameobjects script
Is this possible to do or do I have to store them in a separate array and somehow make sure that they are components of the current gameobject Im working with.
(I tried it and whatever I did Unity didnt like it.)
Your answer
Follow this Question
Related Questions
Checking for objects and adding to array 1 Answer
Array values changing after gameObject is instantiated from prefab 1 Answer
How do I acces a specific GameObject within the terrain???? 0 Answers
How do you make an array out of an Assets subfolder containing Prefabs? 2 Answers
I build a game to webGL type, It can't get json data from php... 0 Answers