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);
}
}