- Home /
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.
 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;
         }
     }
 }
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
How do I update the position of different prefabs to the current position? 0 Answers
How do I update the position of different prefabs to the current position? 0 Answers
How do I update the position of different prefabs to the current position? 2 Answers
How do you set up a large project? 1 Answer
 koobas.hobune.stream
koobas.hobune.stream 
                       
               
 
			 
                