iPhone Flick shooting

Hey

Im working with unity and iPhone, and I need to use a "flick" to shoot.

A "slow" (a flick = 1sec) should result in a slow shooting speed, and a "fast" flick (flick = 0.1 sec ?) should result in a fast shot.

What are the standards for a flick? 150pixel at the y-axis? cant seem to find any information.

for (var i = 0; i < iPhoneInput.touchCount; i++) { 

        var touch = iPhoneInput.GetTouch(i); 

        if (touch.phase == iPhoneTouchPhase.Began) {
            cachedTime = Time.time;
            firstFinger = touch.position;

        } else if (touch.phase == iPhoneTouchPhase.Moved) {
            if (touch.position.y-firstFinger.y > 150 ) {

                throwTime = (Time.time-cachedTime);
                            // Max (slowest) throwTime
                if (throwTime > 0.75) {
                    throwTime = 0.75;   
                }

                Shoot(throwTime);
                break;  
            }
        } else if (touch.phase == iPhoneTouchPhase.Ended) {
            cachedTime = 0;                     
        }           
 }

I also tried with deltaPosition.y, but then I couldnt use a "slow" shot...

It seems to work OK (above), but im not satisfied. Could need some tips!

Thx

Here, try this script:

var mouseStart;
var mouseEnd;
private var GetVelocity = false;
var DartVelocity;
var FlickTime = 0;
var flickLength = 0;
var DartSpeed = 0;
var worldAngle;
var thrower = false;
var rotate = false;

function Update () {
       if (Input.GetButtonDown ("Fire1")) {
        GetVelocity = true;     
        mouseStart = Input.mousePosition;
        }

        if (Input.GetButtonUp ("Fire1")) {
        GetVelocity = false;
        mouseEnd = Input.mousePosition;

        GetSpeed(); 
        GetAngle();

        Debug.Log ("The speed of your throw was " + DartSpeed);
        Debug.Log ("The angle of your throw was " + worldAngle);
        thrower = true;
        rotate = true;
        Dart.Update();
        }

        if (GetVelocity) {
            FlickTime++;
            }       
}

function GetSpeed () {
    flickLength = (Screen.height - mouseStart.y) - (Screen.height - mouseEnd.y);
    if (FlickTime > 0) {
        DartVelocity = flickLength / FlickTime;
        }
    DartSpeed = DartVelocity / 10;
    DartSpeed = DartSpeed - (DartSpeed * 2);
}

function GetAngle () {
    worldAngle = camera.ScreenToWorldPoint 
        (Vector3 (mouseEnd.x, mouseEnd.y, (camera.nearClipPlane - 100)));
}

That's what you're trying to do. It uses `Fire1` for the input, but you can change that to whatever you want. You can have a slow speed and a fast speed. It also calculates the angle for you and outputs it as `worldAngle`. `DartSpeed` is the speed of your projectile (I was using a dart). Hope this helps!