Mobile games performance, let's be honest

Discussion and feedback on Construct 2

Post » Tue Feb 25, 2014 1:53 pm

I had a quick look at your events. Your collision checks are done very inefficiently.

You have a *lot* of collision checks that look like this:

+ On collision between A and B
+ Var = 1
-> Do something

+ On collision between A and B
+ Var = 2
-> Do something

+ On collision between A and B
+ Var = 3
-> Do something

+ On collision between A and B
+ Var = 4
-> Do something

+ On collision between A and B
+ Var = 5
-> Do something

etc. etc. This example does 5 separate collision checks.

If you use subevents like this:

+ On collision between A and B
----+ Var = 1
----> Do something
----+ Var = 2
----> Do something
----+ Var = 3
----> Do something
----+ Var = 4
----> Do something
----+ Var = 5
----> Do something

That does one collision check, then does a simple check for the variable. This is literally 5x faster than the previous way, and you do this again and again and again in your events.
Scirra Founder
B
387
S
230
G
87
Posts: 24,249
Reputation: 192,250

Post » Tue Feb 25, 2014 2:43 pm

I wonder, is the "Not overlapping" just as hungry as the "Is Overlapping"? Or is it more, because it's happening more often?
B
79
S
12
G
7
Posts: 961
Reputation: 10,717

Post » Tue Feb 25, 2014 4:21 pm

An inverted overlapping condition takes the same CPU as when it's not inverted.
Moderator
B
94
S
33
G
33
Posts: 3,006
Reputation: 27,744

Post » Tue Feb 25, 2014 6:32 pm

@Ashley

+ On collision between A and B (when player pick up a power up)
+ Var = 1 (this is level of power to upgrade in game store)
-> Do something (when level is high do something better)


So its my only idea how behave player when have upgraded level "var 1,2,3 etc.
It is inseparable part of the game and must be, even if this cause performance problem, I have no a better idea before how to minimize it.

i take your tips
B
109
S
25
G
43
Posts: 1,883
Reputation: 33,553

Post » Tue Feb 25, 2014 7:37 pm

@delgado - I might be misinterpreting your post, but as Ashley said you're doing redundant work. Read up on sub events: https://www.scirra.com/manual/128/sub-events

Sub events remember the picked instances of the parent events, so you only need to do one collision check, and the sub events that compare a variable will continue to only check and act upon the picked instances of the parent event.
Moderator
B
94
S
33
G
33
Posts: 3,006
Reputation: 27,744

Post » Tue Feb 25, 2014 7:49 pm

@Arima yeah i do it for all similiar colisions condition i check CPU usage and i saw no better: Image
B
109
S
25
G
43
Posts: 1,883
Reputation: 33,553

Post » Tue Feb 25, 2014 10:42 pm

Image

The top way requires 5X more collision checks for the same outcome.

Image
B
70
S
24
G
19
Posts: 1,757
Reputation: 17,614

Post » Tue Feb 25, 2014 11:53 pm

@Silverforce yes i understand this and i implement this, result is on upper screenshot.
Any other ideas?Image
Last edited by delgado on Wed Feb 26, 2014 10:21 am, edited 1 time in total.
B
109
S
25
G
43
Posts: 1,883
Reputation: 33,553

Post » Wed Feb 26, 2014 12:01 am

I dunno because its worse from your screenshot, now its bonkers 80% of CPU for your events but down to 12% for your engine (before your engine was 37%)... so i really have no idea how you put your events together. :(
B
70
S
24
G
19
Posts: 1,757
Reputation: 17,614

Post » Wed Feb 26, 2014 12:53 am

@delgado

Might be able to help. Sent you a PM
B
44
S
10
G
10
Posts: 1,106
Reputation: 9,187

PreviousNext

Return to Construct 2 General

Who is online

Users browsing this forum: No registered users and 5 guests