Quantcast
Channel: Questions in topic: "log"
Viewing all articles
Browse latest Browse all 235

How can I change touch location to map location?

$
0
0
I am trying to locate a cube object at the position where I touched with this code. However, the only result I can see is "Touched". I think ScreenToWorldPoint is not working. Did I made a mistake in this code? // Use this for initialization void Start () { } // Update is called once per frame void Update () { if (Input.touchCount > 0) { UnityEngine.Debug.Log("Touched"); Vector2 pos_2 = Input.GetTouch(0).position; Camera camera = GetComponent(); Vector3 pos_3 = camera.ScreenToWorldPoint(pos_2); UnityEngine.Debug.Log("pos_3: "+pos_3); //Vector3 pos_3 = new Vector3(pos_2.x, pos_2.y, 0); transform.position = pos_3; } } }

Viewing all articles
Browse latest Browse all 235

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>