상세 컨텐츠

본문 제목

Unity Mouse & Touch Position Convert World Position Code

개발생활/Unity Engine

by 한국인맛집 2018. 10. 22. 12:26

본문

반응형



if(Input.GetMouseButtonDown(0)) {
         Vector3 p = Input.mousePosition;
         p.z = 20;
         Vector3 pos = Camera.main.ScreenToWorldPoint(p);
         Instantiate(obj, pos, Quaternion.identity);
     }
     if(Input.touchCount >= 1 && Input.GetTouch(0).phase == TouchPhase.Began) {
         Vector3 p = Input.GetTouch(0).deltaPosition;
         p.z = 20;
         Vector3 pos = Camera.main.ScreenToWorldPoint(p);
         
          Instantiate(obj, pos, Quaternion.identity);
     }
	 

반응형

관련글 더보기