1
\$\begingroup\$

I have made a 3d version of space invaders. I made all the assets myself in Blender. I feel that it's a very basic game and my Galaxy Note 3 test device should handle it no problem. (Although it's a few years old now so perhaps some kind of shader issue or something that my phone not updated enough for ?)

There are 55 enemies all with one mesh each. There's the flying saucer model and the player model.

Then there's a plane for a background, and 4 defensive meshes (although I've tested without these and the result is the same).

Basically, it all runs superbly (I have turned down much of the lighting and graphics quality etc, but have left basic shadows in). However I notice that if the player just lets the phone sit there in game without touching it, there is very slight (but noticeable) frame lag.

All the enemies have a very short animation which moves its arms a small amount.

I could post the code but its massively unorganized and really quite an embarrassment (HAHA!). Also I'm not sure what parts are relevant so it would be a huge post.

Is there any known issues that can cause the lag only when not being touched? As I feel like some of my old projects might have had this happening too but they've been deleted now unfortunately so I can't really dabble with it.

It works smooth as silk in the Unity Editor Android 'emulator' and as I say, if I actually play the game on my phone it's smooth too.

\$\endgroup\$
1
\$\begingroup\$

Most likely the phone goes into power saving mode and reduces CPU/GPU speed when there is no user interaction for a while.

This is at the OS level.

There may be a setting on your phone to disable this behaviour but your battery life will suffer as a result.

\$\endgroup\$
1
\$\begingroup\$

You can have a look at the Screen.sleepTimeout property and initialize it to:

 Screen.sleepTimeout = SleepTimeout.NeverSleep;

Documentation link: https://docs.unity3d.com/ScriptReference/Screen-sleepTimeout.html

\$\endgroup\$
  • \$\begingroup\$ thanks for this too. I never even thought of this. I will add this asap. However i must say i think there might be another cause also, as the slowdown happens within seconds of letting go of phone, and goes away as soon as i use it. I think there must be some way of forcing the app to be highest priority, but now I have some idea of what to research. \$\endgroup\$ – Big T Larrity Aug 12 '17 at 20:07
  • \$\begingroup\$ What does that do? How can this fix the issue at hand? \$\endgroup\$ – Alexandre Vaillancourt Aug 13 '17 at 1:22
  • \$\begingroup\$ @AlexandreVaillancourt It actually did not fix it, i tried adding this and didnt notice any performance increase. I've tested it a lot now and can say 100% certain that the frame lag only occurs if you leave your hands off the phone for 1 sec or more. As soon as I grab and start playing the lag is gone \$\endgroup\$ – Big T Larrity Aug 13 '17 at 12:41
  • \$\begingroup\$ @SupeMegaBroBro The comment was intended to the answer's author, as the answer doesn't say much about what the issue is... \$\endgroup\$ – Alexandre Vaillancourt Aug 13 '17 at 12:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.