IEnumerator pickSizePowerUp()
{
gameobjectToChange[0].transform.localScale += bordersSizeChange;
gameobjectToChange[1].transform.localScale += bordersSizeChange;
GetComponent<SpriteRenderer>().enabled = false;
GetComponent<CircleCollider2D>().enabled = false;
yield return new WaitForSeconds (durationOfPowerUp);
gameobjectToChange[0].transform.localScale -= bordersSizeChange;
gameobjectToChange[1].transform.localScale -= bordersSizeChange;
}``` how do i make it such that this code works cuz this is on an instantiated object
I wanna make it such that if you collect this, the 2 "rackets" grow bigger
#I can't use FindObjectOfType or any .find, please read this whole thing first.
1 messages · Page 1 of 1 (latest)
I don't understand what exactly what you want but I think you want a reference to them, you could accomplish that by saving a reference to it in a game manager or the exactl class you need when you instantiate them
@tough sequoia
basically, the gameobject arrays' scale I want to change cant be dragged into the inspector cuz this is an instantiated object. I can't use gameobject.find or any find syntax
Yeah, so all you have to do is store them in the script, when you call Instantiate it returns the game object that has been created, so all you have to do is set the fields if the array through script with the objects returned from the instantiate method
Bruh who did I mention xD
i dont understand, maybe cuz im hungry
XD
I will give you an example
GameObject go = Instantiate(prefab, position, rotation);
go.transform.localScale += value;
gameObjectsToChange[0] = go;
You might need to do an explicit conversion for the GameObject but anyway the object that it returns can be stored anywhere and used like so
gameObjectsToChange[0] = Instantiate(prefab, position, rotation);
gameObjectsToChange[0].transform.localScale += value;
You can also do this
After this it just depends where you instantiate your game object