- Home /
 
               Question by 
               ScreamyCat · Feb 12, 2020 at 06:22 PM · 
                gameobjecttransformpositionvector3distance  
              
 
              how do i fix my script in the content below?
I am trying to make the first prefab know if there is the same prefab next to it. Although when I place down clones of my prefab the clones only look for the original prefab which is not in the gam scene and has the transform values of 0, 0, 0. How can I fix so my prefabs clones are looking for each other and not the original?
(TowerMerge is activated by a button in the game scene!)
 public void TowerMerge()
 {
     if (slingshot != gameObject)
     {
         float dist = Vector3.Distance(slingshot.position, transform.position);
         print("Distance to slingshot: " + dist);
         if (dist < 5f)
         {
             Debug.Log("Fused");
         }else
         {
             Debug.Log("No towers nearby");
         }
     }
 }
               Comment
              
 
               
              Your answer
 
 
             Follow this Question
Related Questions
Reposition to minimum distance from target 2 Answers
distance to variable object 1 Answer
Distance won't work 1 Answer
charachters stand next to each other 0 Answers
 koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                