Question by 
               AdrianMer · Apr 02, 2018 at 05:14 PM · 
                androidgameobjectinstantiate  
              
 
              ,Instantiate at touch position
Hello,
i want to instantiate a gameobject at the touch position, the gameobject get's instantiated however way off the screen at like x: 300 y: 200!
 public class InstGameobjectTouch : MonoBehaviour {
 
     // Use this for initialization
 
     public GameObject prefabToInst;
     Vector2 touchPos;
 
     void Start () {
         
     }
     
     // Update is called once per frame
     void Update () {
 
         touchPos = Input.GetTouch (0).position;
 
         if (Input.touchCount > 0) {
             
             Instantiate (prefabToInst, touchPos, Quaternion.identity);
 
         }
 
     }
 
 
 }
,Hello,
i want to instantiate a gameobject at the touch position, the gameobject get's instantiated but way off the screen. If i check the coordinates of the instantiated objects they are all around x: 300 y: 200.
 public class MoveCameraToTouchPosition : MonoBehaviour {
 
     // Use this for initialization
 
     public GameObject prefabToInst;
     Vector2 touchPos;
 
     void Start () {
         
     }
     
     // Update is called once per frame
     void Update () {
 
         touchPos = Input.GetTouch (0).position;
 
         if (Input.touchCount > 0) {
 
             Instantiate (prefabToInst, touchPos, Quaternion.identity);
 
         }
 
     }
 
 }
               Comment
              
 
               
              Your answer
 
 
             Follow this Question
Related Questions
instantiate prefab at every gameobject with tag 0 Answers
Stuttering in build 0 Answers
Problem with destroying a gameobject 2 Answers
How to instantiate a game object every time when space key is pressed 2 Answers
 koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                