I wrote this script to make the object move to the position, where the player touched. It gets the finger position correctly, but does not change it to world point value. If I were to use the original value, the object would move far away.
using UnityEngine;
using System.Collections;
public class Player : MonoBehaviour {
public Vector3 realPos;
public Vector3 tempPos;
// Update is called once per frame
void Update () {
if(transform.position != realPos) {
transform.position = Vector3.Lerp (transform.position, realPos, 0.3f);
}
if(Input.touchCount > 0 && Input.GetTouch(0).phase == TouchPhase.Began) {
Vector3 fingerPos = Input.GetTouch(0).position;
tempPos = fingerPos;
tempPos.z = 0;
realPos = Camera.main.ScreenToWorldPoint(tempPos);
realPos.z = 0;
Debug.Log (tempPos);
}
}
}