How do I update the position of different prefabs to the current position?

Hello everyone,

I’m making a game where the player is a square and it changes shape when he presses a key.
To do that I made different prefabs because I have different things to change. When I press the key to change to one prefab, I set active the corresponding prefab and I disable the other.
The problem is here, I have three prefabs and I don’t know where to connect to change the position runtime. I tried to make the position equal to the others but it didn’t work.
Here there is the code I made:

using UnityEngine;


public class Transformation : MonoBehaviour
{   
    public GameObject normal, small, big;

    // Start is called before the first frame update
    void Start()
    {

    }

    // Update is called once per frame
    void Update()
    {
        if (Input.GetKeyDown("q"))
        {
            big.SetActive(true);
            normal.SetActive(false);
            small.SetActive(false);
            big.transform.position = normal.transform.position = small.transform.position;
        }
        if (Input.GetKeyDown("w"))
        {
            normal.SetActive(true);
            big.SetActive(false);
            small.SetActive(false);
            normal.transform.position = big.transform.position = small.transform.position;
        }
        if (Input.GetKeyDown("e"))
        {
            small.SetActive(true);
            normal.SetActive(false);
            big.SetActive(false);
            small.transform.position = big.transform.position = normal.transform.position;
        }
    }
}

Hi
I would recommend a slightly different approach.
As I understand all prefabs should be in the same position.

You should do 1 object (or 1 prefab) called for example CharacterObject.
And put your 3 small, big and normal inside.

Then when you changing position just change the position of CharacterObject.
And don’t move prefabs individually.

In this way your 3 prefabs will be always aligned in in same way relative to each other.

Let me know if this helps.

Hi @LOSTSOUL86, but the problem is that I have three different player controller, one for each prefab.
So If I do that I need to put all the different player controller in the same game object and activate only one of them when needed.
How do I set active a component? Using “on enable”?