Question by 
               Hakaysha · Jun 15, 2016 at 01:24 PM · 
                transformarraydrag-and-drop  
              
 
              Arrays - picking a random object
I've been trying to find a concrete answer for this question, but all answers have not been working
The player has to drag & drop several hints on spaces and all of the spaces should accept the hint. I was trying to work with arrays, but the transform.position does not work in this context. so far the script looks like this:
     private GameObject [] tri;
     private GameObject []space;
     private Vector3 screenPoint;
     private Vector3 offset;
 
     void OnMouseDown() {
 
         offset = gameObject.transform.position - Camera.main.ScreenToWorldPoint(new Vector3(Input.mousePosition.x, Input.mousePosition.y, screenPoint.z));
     }
 
     void OnMouseDrag()
     {
         tri = GameObject.FindGameObjectsWithTag("hints");
         Vector3 curScreenPoint = new Vector3(Input.mousePosition.x, Input.mousePosition.y, screenPoint.z);
         Vector3 curPosition = Camera.main.ScreenToWorldPoint(curScreenPoint) + offset;
         tri[].transform.position = curPosition;
     }
     void Update () {
         space = GameObject.FindGameObjectsWithTag("space");
         Vector3 V = tri[].transform.position;
         Vector3 V2 = space[1].transform.position;
         if (Mathf.Abs(V.x - V2.x) < 1f )
         {
             Debug.Log("I'm there");
             LockPlace();
 
         }
     }
     void LockPlace(){
         tri[].transform.position = space[1].transform.position;
 
     }
 }
               Comment
              
 
               
              Your answer
 
 
             Follow this Question
Related Questions
How to instantiate bullets in multiple transforms 1 Answer
Need assistance with an primitive AI. 0 Answers
Quaternion.RotateTowards for camera positions is buggy 1 Answer
Array transform.position from another script 1 Answer
How to transform position of one object to the exact position of another object? 0 Answers
 koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                