how to changes color of the 3rd gameobject by colliding and destroying 1st and 2nd gameobjects

Hi All,
Here is the scenario
I have 6 different objects which are randomly instantiated every 5 seconds.

suppose say if we drag and collide with the gameobject which having same name “one” i am destroying those two gameobjects and instantiate another gameobject with name “two”.

My problem is i have power up in the game in which it changes the color of that gameobject. i want that effect to be transfered to the newly instantiate gamobject when the collision is done as explained above.

it should only transfer when we drag and collide the power up given gameobject.
can anyone explain how to proceed with this scenario.

Set a new GameObject variable as your created objected :slight_smile:
Like so;

public GameObject newEffectedGameObject;

GameObject ourNewObject = (GameObject)Instantiate(newEffectedGameObject, transform.position, transform.rotation);

ourNewObject.GetComponent <Renderer>().material.color = Color.green;

You’ll have to modify the code to get it to fit your needs, but you mainly want to focus on the Instantiate part.