confusing performance

Discussion and feedback on Construct 2

Post » Fri Feb 27, 2015 1:08 pm

Hasuak wrote:If you're using On Collision, maybe try Trigger Only Once with it? I don't remember if that's possible, but triggering stuff only once always saves performance.

heh, "ass_destroyer"


That the whole problem with "On collision" you can't optimize it. It will trigger when there is a collision. So its like a "On created", "On destroyed" etc. That's why you should only use "Is overlapping". Something is just not very good in "On collision" but don't know what it is. But since its a trigger like "On created" I imagine that maybe C2 uses a lot of resources to constantly check whether it should trigger or not. But honestly its just a guess.
B
44
S
11
G
2
Posts: 1,182
Reputation: 6,828

Post » Fri Feb 27, 2015 1:09 pm

@nimos100 - I get you, yeah that makes sense I'll go through an optimize that way, turning off collisions on sprites that are just for background art for example?

I like the distant object off / on example, I wonder how it works with physics, what's the difference between collision properties and collision box 2d?
B
43
S
13
G
8
Posts: 612
Reputation: 7,372

Post » Fri Feb 27, 2015 1:15 pm

CrudeMik wrote:@nimos100 - I get you, yeah that makes sense I'll go through an optimize that way, turning off collisions on sprites that are just for background art for example?

I like the distant object off / on example, I wonder how it works with physics, what's the difference between collision properties and collision box 2d?

You shouldn't spend time disable objects that doesn't require collision checks, that doesn't help. Only those that are involved in collisions.

Im not sure about the physics, but if you can disable collision for those objects the same way as for normal objects, I can't see why you shouldn't get a performance increase, but I don't know the physics functionality that well, so you would have to check if that's the case or even possible.
B
44
S
11
G
2
Posts: 1,182
Reputation: 6,828

Post » Fri Feb 27, 2015 1:44 pm

I find no difference between On collision or Is Overlap.

Ran through this battle (https://www.youtube.com/watch?v=49ct_qX3lSc) a few times with the different collision/overlap triggers. Similar checks per tick, cpu usage, etc.

I normally only use On Collision because it triggers once by default and thats what I need most of the time.

@CrudeMik For physics, they can be disabled separately to the normal collision. There's two layer of collisions for objects with physics.
B
70
S
24
G
19
Posts: 1,757
Reputation: 17,614

Post » Fri Feb 27, 2015 2:11 pm

Silverforce wrote:I find no difference between On collision or Is Overlap.


That sounds weird, because there is no doubt when I test it that I get a huge difference in performance, do you have any data to show, that would be interesting to see?

Like how many objects etc. would like to see that.
B
44
S
11
G
2
Posts: 1,182
Reputation: 6,828

Post » Fri Feb 27, 2015 3:14 pm

asteroid overllaping wth asteroid is the culprit, it will cause asteroid.count^2 collision checks per tick If I am correct.

overllaping and on collisions are actually similar, sometimes you can gain a little with overllaping as it is not checked as much in case of movement or creation.

also disabling collisions between the player and a far away asteroid could be in some cases a complete de-optimisation as if they are not in the same collision cell, no check is done, so make measurement first.
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 » Fri Feb 27, 2015 3:47 pm

Aphrodite wrote:overllaping and on collisions are actually similar, sometimes you can gain a little with overllaping as it is not checked as much in case of movement or creation.


There is a difference between them as I see it. Take this example, this program does absolutely nothing at all. The code you see is all there is. I let it run for a few seconds so it settles. One is disabled for each test ofc.

Image

Check the CPU util...now if I increase the number of yellow squares and still this program does nothing at all, than check the CPU changes.

Image

If these functions are the same then how would you explain the severe increase CPU util from one to the other, when the program doesn't do anything? I agree with you that according to the manual they do the same, but clearly they do not give the same performance.
B
44
S
11
G
2
Posts: 1,182
Reputation: 6,828

Post » Fri Feb 27, 2015 5:03 pm

@CrudeMik About optimizing collisions, read this: https://www.scirra.com/blog/ashley/6/co ... on-in-r155

IsOverlapping & OnCollision both use collision cell optimization, so there's no need to filter down the number of checked instances. From that blog: "If Is overlapping (or On collision) comes after another condition which has picked certain instances, it can no longer use collision cells."

In the events you've shown, the 'asteroids OnCollision with ass_destroyer' is fine, but as you said the 'family asteroids IsOverlapping family asteroids' is expensive if it runs every tick. But I think you've only got that happening at the start. So I'm not sure where the problem is.
B
27
S
12
G
1
Posts: 157
Reputation: 3,359

Post » Fri Feb 27, 2015 5:09 pm

@nimos100 not sure but AFAIK the debbuger can add an overhead, to be really fair you also have to make them behave the exact same way too to really evaluate a waste between the two (is overllapping does not have to verify if it was already colliding with the same exact instance in the past, while on collision does, also not sure what happens if you have 2 collisions at the same time that occurs between 1 sprite2 and 2 sprite in the same tick between on collision and is overllaping).

but that is interesting.
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 » Fri Feb 27, 2015 5:12 pm

nimos100 wrote:Its primarily the "On collision" under setup, try to disable that and let it run again. You shouldn't use "On collision" it is a performance killer :)


and what you suggest to replace "on collision" ?

overlapping ?

and what is the difference between them
B
44
S
16
G
8
Posts: 791
Reputation: 8,279

PreviousNext

Return to Construct 2 General

Who is online

Users browsing this forum: Litoghvgvgv and 3 guests