Android game lags - how to optimize?

Hello,

I beg you for advice, and what I could do to optimize the Android game.

since my game is almost over, I’m trying it out on my smartphone now. however game lags, when a player moves game lags every few meters (pictorially explained).

so lags is happening only when the player is moving.

the game’s resolution is 640x360, I’m just not sure which settings from the image below are the most optimal.

if I choose the second option: nearest. then it suggests that I need to turn off the smoothing option for all images. can this option affect the operation of the game?

does FPS should be 60 for maximum or ?

otherwise the size of my PNG images are mostly a couple of kb, or even less than 1kb for all objects
like enemys, buildings etc…

so I don’t know what I can do to stop lags in game.

Can this maybe be a problem:

Thank you

Just an observation - you’ve got 2 repeat for each enemy in that screen shot. If you have a number of repeat blocks, they could contribute to lag. I suggest that you filter the objects you are repeating over first, and then repeat over that subset of objects.

Take for example that raycast check. You are raycasting for all enemies, every frame. But the raycast distance is only 650 pixels, and all that gets done is object variable Alerte is set to 1. Ideally you should only do the raycast on enemies who are within 650 pixels of the player and have an object variable Alerte that is not 1. So do a normal event with these conditions, then have the raycast as a subevent.

Secondly, you should try to group events with the same conditions and use subevents on them. So from this :

image

to this :

image

I’m just using this as an example. The difference that would make is probably negligable. But with more processor hungry conditions, it has an accumulative affect. By reducing the number of conditions, it may help speed up the game.

2 Likes

Hello,

Thank you for the explanation. I’ll make those corrections.
please can you tell me how i should write raycast ?
How to do only the raycast on enemies who are within 650 pixels of the player ?

Thank you

Like this :

image

The raycast is only performed for the enemies within 650 pixels of the player that are not already on alert.

1 Like

Thank you. I will do that.

purely out of curiosity, I deleted everything from the raycast.
after that i did the export for Android.
but game again lags without raycast.
therefore raycast is not a problem…
:frowning:

i have done a screen record, please see:

when I move, occasionally lags in the same way like before

what could the problem be ?

Thank you

That’s not lag. A lag is a slow down or a pause in the display. What’s in the video appears to be a bit jerky, like it’s correcting or taken a jump in camera movement.

How are you moving the player - platformer behaviour, or a set number of pixels per frame?

1 Like

ok. here is the info:

Thank you

Those code snippets doesn’t appear to have anything that could be causing the jerkiness.

Do you position the camera on the player as one of the last events, so it occurs after the player placement has been done?

1 Like

At this moment camera event is almost at beginning of scene.
but it is after player animations.

what can i check also ?

also are this settings ok ?

Thank you

anyone please

:frowning:

thank you

Hi
I read your question correctly and I told it to my elder brother. He is a game develper and I have shared it with my friends. As soon as I get the best answer, I will tell you here Android game lags - how to optimize? - #11 by Kylenkennett10elo

1 Like

Thank you

I really appreciate it

Try different devices and try different exports, but don’t try duplicate topics.
The game Vai Julietta had a similar issue, I believe. Check if/how it was fixed.

Is this topic: Apply Force performance Issue - #46 by IttaloXD

If yes, i dont see a solution.

I tried on different devices, and the problem stays.

hello,

i have asked on some other places, and one user told me this:

In my experience this is because of half pixel coordinates.

so my question is:

What is half pixel coordinates

How to fix it

Thank you

Better ask whoever told you this. :thinking:
This is an example of sub-pixel coordinates:
image

Can you share a liluo build of your game?

hi,

i can share my files. but you need to test it on Android smartphone.
because my game has only problems on smartphone.
as on computer works normally.
if you can test it on smartphone, please tell me
and i will send you download link

I meant you could share a web export, not the whole project, but either way, yes, I have an Android to test it.

1 Like

ok. i have sent you msg with download link

thank you

Unfortunately, I’m unable to notice any issue on my own mobile phone. :confused:
It’s very smooth, both as apk and in network preview.

@IttaloXD
Hi!
Did you eventually find the culprit to the performance issue you were having with your Vai Julietta game? I suspect @bundyboy is having the same problem.

1 Like