Hi guys, i've got a "1-frame-off" problem with the inputs on iOS.
Here's the example code:
MyMobileInput.uc
MyController.uc
Output:
Facts:
- I thought about managing the inputs this way (when the controller is ticked) 'cause I have a lot of heavy operations to manage and I need to execute them once a frame, when I have already detected ALL the inputs.
- there is a delay of 1 frame (i've set the UDK to 60fps, thus the '0.0161') between the input and the management in MyController.
If we take the order of tick execution in consideration, 'PlayerInput' is a component of 'PlayerController' so his code will be executed after it... this might explain the delay.
So i'm asking you: is there some kind of workaround?
(btw yes, i know it's just an extremely little delay, but i will be happier without it...)
Here's the example code:
MyMobileInput.uc
Code:
class MyMobileInput extends MobilePlayerInput within GamePlayerController; var int counter; var float mytimestamp; function InitInputSystem() { super.InitInputSystem(); //manage the touch events OnInputTouch = HandleTouchEvent; } function HandleTouchEvent (int Handle, ETouchType Type, Vector2D TouchLocation, float DeviceTimestamp, int TouchpadIndex) { counter++; mytimestamp = WorldInfo.TimeSeconds; }
Code:
class MyController extends UDKPlayerController; /** Cache a reference to the MobilePlayerInput */ var MyMobileInput MMI; event InitInputSystem() { Super.InitInputSystem(); //Get a reference to the local MyMobileInput MMI = MyMobileInput(PlayerInput); } event PlayerTick( float DeltaTime ){ super.PlayerTick( DeltaTime ); //if i have some touch events if (MMI.counter > 0) { //print the difference in time and reset the counter. `Log( "Counter: " @ MMI.counter @ " - Difference: " @ WorldInfo.TimeSeconds - MMI.mytimestamp); MMI.counter = 0; //heavy stuff } // heavy stuff } defaultproperties { InputClass=class'MyGame.MyMobileInput' }
Code:
..... [0010.16] ScriptLog: Counter: 1 - Difference: 0.0161 [0010.17] ScriptLog: Counter: 1 - Difference: 0.0162 [0010.19] ScriptLog: Counter: 1 - Difference: 0.0161 [0010.21] ScriptLog: Counter: 1 - Difference: 0.0168 [0010.22] ScriptLog: Counter: 1 - Difference: 0.0167 [0010.24] ScriptLog: Counter: 1 - Difference: 0.0161 [0010.26] ScriptLog: Counter: 1 - Difference: 0.0161 [0010.66] ScriptLog: Counter: 2 - Difference: 0.0161 [0010.68] ScriptLog: Counter: 1 - Difference: 0.0161 [0010.69] ScriptLog: Counter: 1 - Difference: 0.0161 [0010.71] ScriptLog: Counter: 1 - Difference: 0.0162 [0010.73] ScriptLog: Counter: 1 - Difference: 0.0161 [0010.74] ScriptLog: Counter: 1 - Difference: 0.0161 [0010.76] ScriptLog: Counter: 1 - Difference: 0.0164 .....
Facts:
- I thought about managing the inputs this way (when the controller is ticked) 'cause I have a lot of heavy operations to manage and I need to execute them once a frame, when I have already detected ALL the inputs.
- there is a delay of 1 frame (i've set the UDK to 60fps, thus the '0.0161') between the input and the management in MyController.
If we take the order of tick execution in consideration, 'PlayerInput' is a component of 'PlayerController' so his code will be executed after it... this might explain the delay.
So i'm asking you: is there some kind of workaround?
(btw yes, i know it's just an extremely little delay, but i will be happier without it...)