So, I have an array of gameobjects which all has a unique script with only having the same parent script in common. I need to access the script in the gameobject to use a function. The gameobjects will only contain 1 script. Example:
Parent script:
public class Pet : MonoBehaviour {
...
}
Child script:
public class Bird : Pet {
...
}
I don’t understand your question for 100%. But if you would like top reach a function in your base class (Pet), then you should just make it public. Like:
public class Pet : MonoBehaviour {
public void TheFunctionYouNeed() {}
}
Now you can access it through the instantiated object. For example on a bird:
GameObject.Find("Duck").GetComponent<Bird>().TheFunctionYouNeed();
If you want different behaviour on the “TheFunctionYouNeed” function in each derived class, just make it virtual in the Pet class and override it in each class.