- Home /
Decting iOS touch input in Fixed Update
I was detecting touches of the screen in the Update function, however this on iPhone 4 seemed to cause some kind of delays. However, when I moved the code over to the FixedUpdate, it stopped working as expected (multiple inputs detected in jump)
for (var touch : Touch in Input.touches) {
if (touch.phase != TouchPhase.Ended && touch.phase != TouchPhase.Canceled){
fingerCount++;
}
if (touch.phase == TouchPhase.Began && jumpbox.Contains(touch.position)){
jumpKeyPressed = true;
}
I guess, I want to know whether I should detect screen input in Update, or Fixed Update?
Fixed update is used on Physics calculation only and it has a fixed update which wilk make the sim more stable. So you should do it within update. What i dont understand is even if user has a one finger on the screen and just holding his finger. The finger count will increase once per frame which i dont understand why you did sth like that
Answer by Huacanacha · Nov 04, 2013 at 08:18 PM
According to the Unity script reference: http://docs.unity3d.com/Documentation/ScriptReference/Input.html
Touch input is only updated once per frame. The key quote is: "You can access data on the status of each finger touching screen during the last frame".
From my own experience I believe this is the case, although I would love to have more control over the collection of touch input data for my own game.
So the answer is: Detect screen input in Update() :)
Thing is, I have stripped my game now back to it's core, without any fluff and I am still detecting delay in the input. However, or the latest devices this isn't an issue. Odd
Your answer
Follow this Question
Related Questions
The name 'Joystick' does not denote a valid type ('not found') 2 Answers
How do I change the texture of a gameobject only while a touch is on it on iOS? 1 Answer
Input.touchCount returning wrong number 0 Answers
iOS TouchPhase.Began Detected Multiple Times 1 Answer
Touch count & Raycasting on mobile 0 Answers