- Home /
Windows Phone long reaction time
I'm creating a mobile phone phone game. It's also being released on Android at a later time. The game seems to work pretty good, on computer. When I'm testing the game on my Windows Phone Device via USB, it has a very long reaction time (it lags like crazy). My character is falling down and will move up when pressing the fire key (mouse button click). But for some weird reason the click has a long reaction time. The character (object) doesn't go up immediately, but a few milliseconds later. It's very frustrating.
Because I have no clue what is causing this ugly bug, I'll just paste the code to move the object/character.
void Update()
{
if ( Input.GetButtonDown("Fire1"))
{
rigidbody2D.velocity = new Vector2(rigidbody2D.velocity.x, 0);
rigidbody2D.AddForce(new Vector2(0f, 390));
}
}
I think this is not causing the delay, something in the Update routine or a for/while condition that u made. Review it.
@Stormizin I'm using a parallax scrolling system from someone else. I had no problems with it actually. I've also got a for-loop with a while-loop in it to automatically instantiate objects. I thought that could be it, but disabling the script doesn't fix it. Nor disabling the infinite background loop in the parallax scrolling system. I have no idea what is causing the lags. $$anonymous$$y application even crashed.
I've tried to disable a lot of functions in the update routine, such as: A script to stay in boundries of the screen, parallax scrolling script, infine background script, the loop to instantiate objects..
Is there some sort of crash log available?
Answer by meat5000 · Feb 07, 2014 at 01:07 PM
If you have some profiler running it may cause lag on the gpu, I hear. Also if you have a lot of code in your touch routine compared to the moment it detects a touch it may seem unresponsive.
Nullrefs and console debug entries will also cause things to slow down. Fix errors and reduce debug output, or use a non-dev build to see what it runs like with that stripped out.
Also, Physics routines, like Rigidbody AddForce should be performed in FixedUpdate() function, not Update() which is framerate dependent.
It is not possible to properly detect if a key has been pressed in FixedUpdate().
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Distribute terrain in zones 3 Answers
Objects not becoming active with script 1 Answer
Unity5 build issue, not showing texture. 1 Answer
2D Platformer Bug 0 Answers