Mobile Game Imporvements

Hi,
I am very new to Unity. But I ve already developped some 2D Games for PC. Now am developping an App for mobile devices. It is almost finished but I have some performance problems. So my question is what things could I improve. If you need more information, I will give them to you. Here is my Profiler while I am playing the game on my LG G4:

Thanks for you help!
Jan

It depends what’s going on in the scene reduce texture sizes? Reduce number of objects that need to be rendered? Simplify lighting

You have only 5 batches and steady 60 fps…
It’s already good I think…

Thnaks for your answer.
So for textrues used one spritsheet which is 2048x2048. I have one player object, which is a rocket, and about 20 asteroids. Therfore I am using a prefab. Finally I remove the lighting at all. So Ithink this isnt the problem. :frowning:

Yeah, it seems to be good, but when i play this on my phone it is a bit halting. I am sure there must be a way to get rid of this, but I dont know how.

Are you using Destroy on the asteroids? and then instantiating them?

No I use a stack. At the beginning I generate about 20 of them and then I reuse them every time.

Okay so its not that, what about bullets do you uses bullets to deactivate the asteroids? are you pooling the bullets so you don’t fire too many?

You just control the rocket/player by tapping on the screen(on tap control) and then you have to dodge the asteroids falling down.
I deactivate and activate these asteroids. Could this be a reason?

No if your pooling asteroids then that’s fine, can you define halting? are you using update or FixedUpdate to move the asteroids and ship?

Your cpu is completing its task’s in 10 ms which is 100 fps, so it has to be the gpu being slow why not show the profile of the gpu? how many loops do you have ?

The game is almost smooth, but every secend there is a small jank. I dont move the asteroids at all I generate them and my rocket/player moves (fixed Update) through them. After a asteroid leaves the screen I deactivate and reuse it.
I have single loops but not just for generating (not spawning!) the asteroids.

Here you can see some mor infos about Rendering:


thanks again for your quick answers!

Okay what method do you use for detecting if a object has left the cameras view? That could be looping through an awful lot of asteroids and having to do checks on each one weather it is within the view port of the camera. If the rocket can move in any direction like this game:

-then an object that just had a check and moved to a different position can then if they turn be checked over and moved again stacking up a ton of math calculations on the cpu. if its a cluster then that could cause a massive spike in calculations causing a slight stutter.

Fixed Update is probably the issue. It will not be exactly in sync with the frame updates, so occasionally you will either not get an update within a frame, or occasionally it will happen twice.

This is the reason I do all movement in Update and multiply the speed by Time.deltaTime. That make movement and frames in sync.

If you do not wish to make that change, the best you can do is go into the Project Settings for Time and set Fixed Timestep to 0.016667 (1 divided by 60, your frame rate). Then it will happen much less often.

In my Game the camera moves in y axis but is fixed in x axis. So i have one trigger element which detects the steroid and then the asteroid will be deactivated after some secends (IEnumerator). If the rocket/player leaves the screen on the right or left side it will appear on the other side of the screen again(like doodle jump). But i am going to check my scripts again for some mistakes.

I thought that if you have a rigidbody with a collider and the Physic System, then you should use FixedUpdate.
Anyway I will test this and then I will give Feedback again.

Yeah fixed update is usually used for physics movement because update runs at different speeds on different hardware.

I used this to control the speed of the rocket:

void FixedUpdate () {
if (!isdead) {
gameObject.GetComponent().velocity = new Vector2(speedx , speedy) * Time.deltaTime;
}
}

So, is it wrong to use “Time.deltaTime” in FixedUpdate?

Yes you should use FixedUpdate if you are moving objects with physics. You can use rigidbodies and colliders without physics if you set the rigidbody to Is Kinematic, but it is probably best to continue on your current course as you have gone so far into development.