Question by
hatzii · Jan 05, 2017 at 08:20 AM ·
instantiatepositiontouch
Instantiate at touch.position
void Update () {
fingercount = 0;
foreach (Touch touch in Input.touches) {
if (touch.phase == TouchPhase.Began && fingercount < maxfinger) {
i++;
bh.ScreenTapped ();
this.GetComponent<Animator> ().SetBool ("Tapped", true);
worldPos = Camera.main.ScreenToWorldPoint(touch.position);
worldPos.z = 0;
Instantiate (cut,worldPos,Quaternion.Euler(0,0,Random.Range(80,100)));
GameObject plusch = (GameObject) Instantiate (pluscherrys, worldPos, Quaternion.identity);
plusch.GetComponentInChildren<Text>().text = "+" + bh.ScreenTapped ();
Debug.Log (touch.position);
Debug.Log (worldPos);
}
fingercount++;
}
score.text = i.ToString () + " Tapps";
}
public void TappedFalse ()
{
this.GetComponent<Animator> ().SetBool ("Tapped", false);
}
When I tap on the Screen my Prefab always is in the middle of the screen because the worldPos has always the same coordinates why it does not get the coordianates of the touch.position?
Thanks for every answer :).
Comment