Hi all,
I use this code to move a object on the screen where my finger is moving.
It is working but it’s slow “lag”.
When I move my finger slowly on the screen its following but when you go just a little faster it stops following and I have to go back to the object to reselect it and start moving again.
Is there a way to do this better?
Roy
function Update () {
for (var touch : Touch in Input.touches){
var ray = Camera.main.ScreenPointToRay(touch.position);
var hit : RaycastHit;
if (Physics.Raycast (ray, hit, 100)) {
if(touch.phase == TouchPhase.Began || touch.phase == TouchPhase.Moved) {
var cameraTransform = Camera.main.transform.InverseTransformPoint(0, 0, 0);
object.transform.position = Camera.main.ScreenToWorldPoint(new Vector3 (touch.position.x, touch.position.y, cameraTransform.z - 0.5));
}
}
}
}