#I can't use FindObjectOfType or any .find, please read this whole thing first.

1 messages · Page 1 of 1 (latest)

bleak tundra
#
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
hollow root
#

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

bleak tundra
#

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

hollow root
hollow root
bleak tundra
#

i dont understand, maybe cuz im hungry

hollow root
#

XD

hollow root
#
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