How can I store a game object in a variable, so I could later change another game object into the one stored, like this
Gameobject gb1; //gameobject to change into
Gameobject gb2 = //find the game object to be changed
Start()
{
gb2 = gb1;
}
How can I store a game object in a variable, so I could later change another game object into the one stored, like this
Gameobject gb1; //gameobject to change into
Gameobject gb2 = //find the game object to be changed
Start()
{
gb2 = gb1;
}
I’m afraid it’s not that simple to “transform” a gameobject into another. You would have to adjust/specify all the components as well. Take a look at the Instantiate Documentation, this should be able to accomplish basically what you were wanting to do.
Steps:
Store the gb1 in a variable
When you want to switch the GameObjects, destroy gb2
Instantiate gb1 in gb2’s location