How to save a gameobject moved from scene A to scene B.

A little explanation about the situation…

In playmode I am carrying a gameobject,with the help of parenting, with my player object which is persistent through scenes with DontDestroyOnLoad from Scene A to Scene B and unparent it in Scene B.

Is there a way to somehow save the gameobject and when loading Scene A not find it (because i took it) and when loading Scene B find it in the position I left it?

Thanks in advance.

semi psuedo:

//inside your item code add:

int isPickedUpAlready = 0;

void Start(){
    if(!PlayerPrefs.HasKey("ThisItemPickedUp")){
         PlayerPrefs.SetInt("ThisItemPickedUp", 0);
    }

    isPickedUpAlready = PlayerPrefs.GetInt("ThisItemPickedUp");

    if(isPickedUpAlready > 0) {
         destroy(gameObject); // kill this object
    }
}

// just a functio to call when it's picked up
public void PickedUp(){
    PlayerPrefs.SetInt("ThisItemPickedUp", 1);
}

also player prefs can get a bit sluggish if over used / used wrong ( what I listed here is not ideal but should work to get you going). Best to save prefs on a pause screen or right before loading / quitting so there isn’t stutters in gameplay. Or use one of the many other write to file options for saving data can work as well

Edit : Unity - Scripting API: PlayerPrefs

And for the Scene B (where I ve left the gameobject) I could check the variable and instantiate a gameobject, right? I should also save the position somehow…in 3 vector 3 variables maybe?

I thought as much. So ,for every object I move from one scene to another, I must :

set a variable -->save the current position–> check it -->destroy or instantiate accordingly.

Isn’t there a more efficient - quicker way?