Error With Switching Characters

So, I have this script to change characters in-game, like in Castlevania: Portrait Of Ruin, for example. It seems to work with the switching part, but when the characters change, they don’t stick together. It’s like this: say I move to a corner of a room. Then, I change characters and move to the other corner. Now, when I switch back, the first character appears in the previous corner, as if the game saved where it was located when the switch was made. How can I get them to stay together when I switch?

Regarding my setup: I have two characters inside a parent empty gameobject. The characters themselves have the controls script, rigidbodies, colliders, etc, and the empty gameobject has the switching script. This was the only way I could find to get it to work with the character animations. Here is the switching script:

public GameObject play1, play2;
private int characterSelect;

void Start()
{
    characterSelect = 1;
    play1 = GameObject.Find("Player1");
    play2 = GameObject.Find("Player2");

}

void FixedUpdate()
{
    if (Input.GetButtonDown("Change"))
    {
        if (characterSelect == 1)
        {
            characterSelect = 2;
        }
        else if (characterSelect == 2)
        {
            characterSelect = 1;
        }
    }
    if (characterSelect == 1)
    {
        play1.SetActive(true);
        play2.SetActive(false);
    }
    else if (characterSelect == 2)
    {
        play1.SetActive(false);
        play2.SetActive(true);
    }
}

Once you disable a GameObject all the attached components will be disabled. Even though you have your control script on both objects it will only be active on the active GameObject.

A quick way to get the characters in the same position would be to update the deactivated players transform just before switching characters.

    if (characterSelect == 1)
     {
         play1.transform.position = play2.transform.position;
         play1.transform.rotation = play2.transform.rotation;
         play1.SetActive(true);
         play2.SetActive(false);
     }
     else if (characterSelect == 2)
     {
         play2.transform.position = play1.transform.position;
         play2.transform.rotation = play1.transform.rotation;
         play1.SetActive(false);
         play2.SetActive(true);
     }

That should fix the problem you are having now.

Looking into the future though you might run into similar issues like this. Ignore me if I am wrong but I’m guessing you have the same Control script on two separate GameObjects? Instead of activating / deactivating a multiple players I would recommend just enabling / disabling the visual game objects when you switch characters so that you only have 1 instance of your Control script.