sluggish response to my touch

so i’ve made a touch pad for my iphone game that works essentially just like a directional pad.

the game is running at 60 fps but when i touch the pad it waits a few milliseconds before moving, and when i stop pressing it the vehicle keeps moving for a few more milliseconds before stopping.

my code is as follows

function MainControlLoop(){
    while (true){
        if(LatchedFinger==-1){
            SearchForTouch();
        }
        else{
            TrackFinger();
        }
        yield;
    }
}

function SearchForTouch(){
        var touch : Touch;
        for (var i = 0; i < Input.touchCount; ++i) {
            if (Input.GetTouch(i).phase == TouchPhase.Began) {
                touch = Input.GetTouch(i);
                if(TouchForGUI(touch)){
                    LatchedFinger=i;
                    sendMove(touch);
                    return;
                }
            }
        }

}

function TrackFinger(){
    var touch : Touch;
    

    touch = Input.GetTouch(LatchedFinger);	
    sendMove(touch);
        
    if(touch.phase == TouchPhase.Ended || touch.phase == TouchPhase.Canceled){
        LatchedFinger=-1;
    }
}

function TouchForGUI(touch : Touch ) : boolean{
    if(rect.Contains(touch.position)){
        return true;
    }
    else{
        return false; 
    }
}

function sendMove(touch: Touch){
    var horizontalMove:float =   (touch.position.x- centre.ct.x)/centre.ct.width ;
    var vertMove:float =  (touch.position.y- centre.ct.y)/centre.ct.height ;
    main.pC.MoveTank(Mathf.Clamp(horizontalMove,-1,1), Mathf.Clamp(vertMove,-1,1));
}

i’ve tried converting it to a update or fixed update but it seemed to respond even worse then. which makes me think the delay is in my code somewhere but i can’t seem to find it

never mind problem was solved, i was setting USE_DISPLAY_LINK_IF_AVAILABLE to on which was causing my touch responses to be sluggish

anyone know a way to keep that on without it being sluggish? i liked the performance gain.

I know from experience that USE_DISPLAY_LINK_IF_AVAILABLE can kill input responsiveness on 1st gen devices. Switching off the accelerometer and increasing fixedTimestep so FixedUpdate gets called less frequently solved it for me. If you’re only targeting newer devices, it shouldn’t be as much of an issue.

Your thread title is the same as on a letter I once sent to an agony aunt column in the local newspaper about a girlfriend at the time.

lol

@ jasper, i’ll try making those adjustments, it’s funny cause i’m testing on a 3g and getting that unresponsive problem.

3G == 1st gen iphone . There’s really no hardware difference between 1st (iPhone) and 2nd gen (3G).

Both have a 412 mhz ARM 11, an MBX Lite video chip and 128 mb ram.

Lol, great stuff :slight_smile: