Optimization, Performance HELP

Get help using Construct 2

Post » Tue Feb 18, 2014 3:56 pm

Solid 60 and no sluggishness on my laptop.
B
60
S
20
G
56
Posts: 1,077
Reputation: 35,941

Post » Tue Feb 18, 2014 4:20 pm

Aphrodite lots of good feedback, thanks for taking time to help me, learned a few things. I usually use If/Else on php and other scripting languages, but on Construct 2 the events structure tricked me, now i see clearer with ur examples. Thanks, this helps.

Guizmos, you are right, now i saw that i check for collision all the time with no reason, ill fix, that thanks. Ill check infinite runner, and analyze the tick events.

Good feedback so far, thanks guys, still doesn't explain why 56 events game, with maybe 10 objects on screen and %5 cpu usage is sluggish on mediocre PCs. But i will investigate more and rewrite it based on feedback and more research.

I will re install a fresh copy of windows on my laptop, and do more tests, based on your feedback, and improve the version considerably.

Thanks, and also if others have more insight, let me know.

I really hope that i am doing something wrong(which i will find out in the next days testing heavily part of the code, on my laptop) and is not the engine...





Image
B
30
S
5
G
1
Posts: 125
Reputation: 3,220

Post » Tue Feb 18, 2014 4:29 pm

"Good feedback so far, thanks guys, still doesn't explain why 56 events game, with maybe 10 objects on screen and %5 cpu usage is sluggish on mediocre PCs. But i will investigate more and rewrite it based on feedback and more research."

I think this is because CPU isn't the only thing limiting the fps, the GPU can also limit the fps (Too much memory used by pictures, bad graphic driver can also slow this down I think, but not sure)

Also you have many layers, maybe that also affects that.Aphrodite2014-02-18 16:30:09
Game design is all about decomposing the core of your game so it becomes simple instructions.
B
52
S
22
G
18
Posts: 2,122
Reputation: 17,093

Post » Tue Feb 18, 2014 5:13 pm

From what i read Ashley said layers dont affect performance, of course unless u make a lot of them(unproven). VRAM is at 8mega at the moment.

Ill do some tests when the laptop is ready since i have on board intel on it but also Geforge 410m so i can switch. On my main i cant test, since its a i7, 3ghz, GTX 260 and 8 giga ram(not high end, but over most of the standard pcs.. so it doesnt help)lwgames2014-02-18 17:13:55
Image
B
30
S
5
G
1
Posts: 125
Reputation: 3,220

Post » Tue Feb 18, 2014 6:02 pm

I don't know that much about the C2 engine, but I do think that it have limits, or the program might, not sure. But it doesn't seem to handle lots of objects very well.

But if you play a game like Factorio and the amount of objects it can handle at the same time, its insane. If you don't know it, here is a video to give you an idea.

Factorio video

Basically the game is about building a factory sort of thing, and you produce and extract all kind of different resources or products, which you can then transport around. Each of the small things that you see move around are either a product or resource. And you then have these "arms" that can pick them up and move them around, insert them to machines etc. My point is there are really a lot of things going on, and checks that needs to be made, collisions and so on all the time. Making a game of this kind in C2 I cant see how could be possible, simply because the amount of objects would completely kill it.

But as I started by saying I don't know that much about the C2 engine, but it doesn't seem very hard to kill it you want. Even if you don't try to on purpose. But it would be very nice if it could do something like this. :D

Ps. The game is still under construction, but seems very promising. nimos1002014-02-18 18:12:41
B
44
S
11
G
2
Posts: 1,182
Reputation: 6,828

Post » Tue Feb 18, 2014 6:20 pm

"But as I started by saying I don't know that much about the C2 engine, but it doesn't seem very hard to kill it you want."

Clearly depends on too much things, I have a kind of bad computer (spelunky might be the only game I can think of I can play on it without too much lag, and sometimes there are), but never managed to get bad fps in C2 unless I do really bad design that wouldn't work in native anyway, other have better computer that cannot run properly a simple C2 game, it is just plain weird.
Game design is all about decomposing the core of your game so it becomes simple instructions.
B
52
S
22
G
18
Posts: 2,122
Reputation: 17,093

Post » Tue Feb 18, 2014 6:25 pm

On this, don't forget that lot's of people have either graphical drivers outdated, lots of background process taking most of their CPU and RAM, especially in browsers, where the basic user has toolbars up to the head. "Cleaning" computers everyday, this is a lot more common that some could think.
B
17
S
8
G
4
Posts: 461
Reputation: 6,137

Post » Tue Feb 18, 2014 7:37 pm

I agree with you to some extend. However a lot of performance hit also comes from C2.

I made a small program here, that basically doesn't do anything except moving some small sprites around. You get a massive performance hit.

Which is caused by "on collision", there are added nothing to it. And you are not able to change the way this event works as its part of C2. Now in the program I have added that it should only trigger this if the speed of the sprite is above 0. Which ofc shouldn't make any difference to whether it should check for collisions or not, so removing it, makes no difference. And since the event doesn't actually do anything, it doesn't matter anyway in this test.

But that you cant configure when collision detects should take place, you actually get a performance hit, even though non of the objects starts out moving. As you increase the speed of the objects, it just completely kills it.

On my computer the moment I spawn 350 objects, the fps drop between 20-25 instantly. Even though these objects do absolutely nothing, except being on the screen.

Increase it to 650 objects, still doing nothing and it drops by 49-50.

So even though the computer also plays a part, the C2 engine or what to call it, will be the first thing to kill performance. Im pretty sure my computer can handle rendering 650 sprites :D

In order to improve performance when handling lost of objects, you would need to be able to control when and under what conditions for instant collision testing should even take place.

Whether you could do that with some distance calculations, and avoid the one that are build into C2 I don't know.

Here is the capx if you want to try it yourself:
Performance testnimos1002014-02-18 19:50:01
B
44
S
11
G
2
Posts: 1,182
Reputation: 6,828

Post » Tue Feb 18, 2014 8:25 pm

Sprite collisions with themselves doesn't work well at all (A sprite is overlapping itself constantly)

Bad point Of C2 I think personnally, families can correct that I think, but not sure yet

Also you are checking the collisions for each individual object, let's see...

Number_of_object collisions I think

EDIT:Indeed, checking like that means you check collision of an object with himself, and so the number of collisions to check will be huge, not a C2 problem, every engine would have trouble with this kind of logic, try instead to check collision between 2 different kinds of objects, or add some kind of other testAphrodite2014-02-18 20:47:19
Game design is all about decomposing the core of your game so it becomes simple instructions.
B
52
S
22
G
18
Posts: 2,122
Reputation: 17,093

Post » Tue Feb 18, 2014 9:30 pm

Im not really sure if what you say is correct.

If i make 500 objects, and tell it to test for collision against the same object. I get 18-19 fps.

If i make 500 of another type, and test against them i get the same fps.
So could indicate that it doesn't make any difference, and it does the same amount of tests.

But my point was, that if you take that game i linked earlier, there must be something in the way they do, or handles collision detection that are different than how C2 handles it. As there are no problems in that game to have several 1000 objects interacting with each other. If its because they use some type of range to determine whether an object should do collision check with another i don't know. But I can place 500 objects on the right side of the screen, and make sure that they would never interact or even come close to the other objects, and still fps would suffer. So my guess is that "On collision" simply take one object, and test against every object that its told, regardless of the other object is even relevant for testing or not. And therefore it doesn't matter whether you test 500 objects of the same type against each other, if its different type, if these objects are even close to each other and so on.

ADDED***

Ok fooled around a bit and optimized it a little, so it can now run 5000 objects with around 30 fps, so it was quite and improvement :D

And can run 2500 objects with 60 fps.

But it seems that its correct that it just does a straight up comparison when doing collision testing.nimos1002014-02-18 21:56:22
B
44
S
11
G
2
Posts: 1,182
Reputation: 6,828

PreviousNext

Return to How do I....?

Who is online

Users browsing this forum: ivanski1983 and 12 guests