- Home /
 
               Question by 
               Muneeb992244 · Aug 06, 2019 at 06:35 PM · 
                scripting problemprefabscamera follow  
              
 
              How to make my camera follow a prefab and update it to follow the instance of same prefab the generated after the same prefab ?
I get my camera to follow the same prefab that is generated the first time . But the problem is when a second clone is made the camera fails to follow it and keeps following the first clone .
 public class cameraMovement : NetworkBehaviour
 {
 
 
 
     public GameObject player;
     private Vector3 offset;
 
     
 
 
     // Start is called before the first frame update
     void Start()
     {
         Debug.Log("I was here");
 
         if (player)
         offset.x = transform.position.x - player.transform.position.x;
         
     }
 
     // Update is called once per frame
     void Update()
     {
         if (player == null )
         {
            player = GameObject.Find("Glimmer(Clone)");
 
         }
         else
         {
            transform.position = new Vector3(player.transform.position.x + offset.x, 0f, -10);
         }
 
     }
 }
               Comment
              
 
               
              Your answer
 
 
              koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                