Replacing prefab with another, within script?

I am trying to replace my starting prefab with another, as soon as the player reaches a certain score, in order to commence the next level with a new character. I have tried:
Instantiate(Character2, Vector3.zero, Quaternion.identity) as GameObject;
(this just created multiple copies and then they disappeared).
I have also tried:
GameObject Character1 = Resources.Load(“Character2”) as GameObject;
(which did nothing).
I’m running out of ideas, it seems like such a simple task, to replace one prefab with another while the game is running, but everything I have tried has been unsuccessful, does anyone have any other ideas?

1 Like

Try this:
GameObject Character1 = Resources.Load(“Character2”);
Instantiate (Character1);
Worked for me :slight_smile:
Also, the Character2.prefab file must be in “Assets/Resources”

I receive an error stating that the instance is null.

Where are you calling the instantiate? Are you doing it from within the character script or within some global level manager? Anyway you can post the whole script?

It’s hard to tell what exactly the problem is with the lack of details and debug information. I’d start by commenting line by line until you figure out at what point the objects disappear. Do they get destroyed or are they still in your scene? What do you mean by “disappeared?”