I have 3 instances of a single gameobject (hollow bubbles) which im moving around in my game screen. That has been successfully achieved but now im trying to create 3 another instances of gameobject (the inner bubbles) which follow the first 3 instances of hollow bubbles.
I have created 2 Lists which hold these 3 instances respectively and an array that holds in Element 0 the sprite that i need to add to the inner bubbles that follow the hollow bubbles.
public Sprite[] innerBubblesSprites;
private List<GameObject> yellowBubbles = new List<GameObject>();
private List<GameObject> innerYellowBubbles = new List<GameObject>();
void GameLogic() {
for (int j = 0; j < 3; j++) {
if (i == 0) {
Vector2 yellowPos = new Vector2 (Random.Range (-2.5f, 2.5f), -9.8f);
yellowBubbles.Add(Instantiate(bubbles*, yellowPos, Quaternion.identity) as GameObject);*
_ yellowBubbles*.transform.localScale = new Vector2 (bubblesScale, bubblesScale);_
_ StartCoroutine (“BlinkingBubbles”);_
_}_
_}_
IEnumerator BlinkingBubbles() {
_ for (int i = 0; i < 3; i++) {_
innerYellowBubbles = Instantiate (innerBubblesGameObjects [0], yellowBubbles .transform.position, Quaternion.identity) as GameObject;
_ innerYellowBubbles.GetComponent ().sprite = innerBubblesSprites [0];
yield return null;
}
}*
The 3 instances of innerYellowBubbles are spawning fine in the object hierarchy but all seem to be spawning at the same position and the sprite is also not getting assigned. Further only the first yellowBubble is getting its localScale to the values ive set, otherwise they revert to their default scaling of 1.0. And there is an argument out of range exception. Can somebody please point me in the right direction? Any help would be appreciated. Next ive to make the innerYellowBubbles follow the YellowBubbles as well._