i’m trying to write a script that will allow me to touch an object on the screen of an iPhone and drag it around and when i release it the object stays where i left it, similar to the fruit ninja game (if anyone has played that).
i understand the controls for transforming position of an object using the keyboard but am at a loss as to how i can touch an object and keep the object centre as the touch position.
any ideas / suggestions?
i’ve been experimenting with this method (for mouse first) that i learned on answers earlier
function Update () {
var ray = Camera.main.ScreenPointToRay (Input.mousePosition);
var hit : RaycastHit;
if (Physics.Raycast (ray, hit, 1000) && hit.collider.gameObject.CompareTag("GameController")) {
self.position = hit.position;
}
}