iOS Swiping gesture script...

Hi. I am trying to detect when the user does a swipe gesture and in what direction. I have been told that this can be done by finding
the “velocity” of a touch and then measuring either the x or y components of the Vector2 deltaPosition gives. I tried to set up a basic test to see if I can detect a horizontal swipe but I am getting errors saying: An instance of type ‘UnityEngine.Touch’ is required to access non static member 'deltaPosition(or deltaTime). What is wrong? Thanks

var Velocity_X = 0;

function Update(){
 	Velocity_X = Touch.deltaPosition.x / Touch.deltaTime;
}

The reason is that deltaPosition is not a class method, but an instance method. This means that you can’t just ask Touch for a delta position, it has to be requested from an instance of Touch. Try this for your Update() function:

var Velocity_X = 0;

function Update() {
    if (Input.touchCount > 0 && Input.GetTouch(0).phase == TouchPhase.Moved) {
        var primaryTouch : Touch = Input.GetTouch(0);
        Velocity_X = primaryTouch.deltaPosition.x / primaryTouch.deltaTime;
    }
}