Collisions and Performance Discussion

Discussion and feedback on Construct 2

Post » Fri Aug 04, 2017 4:20 pm

I am an indie developer and was wondering about some collision related questions to improve performance,

First : Every object has a collision property to disable or enable, so will it effect performance if i set collisions disabled for irrelevant objects in the layout?

Second : Every object has a collision mask made of a certain number of points and when we increase those points construct2 warns us to not use more than 8 points in collision mask or it will reduce performance !
So should we reduce the mask points to one for irrelevant objects? (as it is not possible to remove collision mask )

Please reply
Thanks!
B
16
S
5
Posts: 81
Reputation: 1,235

Post » Fri Aug 04, 2017 4:45 pm

if you don't have an event that checks the collision, then you don't need to worry about it. There are no collision checks that are performed.

say you have 100 balls floating in/out of your layout. and everytime your player hits them, they pop. you have to have a statement that says if Player On Collision with Ball. This creates lots of collision checks.

However, if you for some reason, set all the Ball's collision properties to disabled, then that trigger will not happen and not checks are done. Or more constructively, if you set just the balls that are off screen to disabled then you are eliminating unneeded checks i.e. since your player is always in the center of the screen it will never collide with something off screen.

If you have a sprite that is background art and never needs any collision check. You don't need to turn off collisions because you don't have any events for it.
B
88
S
29
G
14
Posts: 1,158
Reputation: 15,011

Post » Fri Aug 04, 2017 5:14 pm

@jobel
Thanks, you just saved my time which i may have spent in disabling collisions for objects in background!

Also, is touching an object event also checks for collisions?
if yes then where does it leave us with the disabling/enabling collision of objects scenario?
B
16
S
5
Posts: 81
Reputation: 1,235

Post » Fri Aug 04, 2017 7:02 pm

I don;t know for sure, but it seems if you use the Touch input type and specify an object it would do a collision check, because it's looking at the collision box in order to know if it interacts with the object.

again the simple optimization is

IF sprite is NOT on screen then disable collisions
else
enable collisions.

but you'd have to have A LOT of objects to make this worth doing. What is your object count?
B
88
S
29
G
14
Posts: 1,158
Reputation: 15,011

Post » Sat Aug 05, 2017 12:30 am

I would recommend not disabling collision checks for off screen objects since Construct already does this for you.
Here is the Blog post about it.
B
79
S
51
G
40
Posts: 370
Reputation: 25,205

Post » Sat Aug 05, 2017 12:35 pm

Thanks @UberLou for info!
B
16
S
5
Posts: 81
Reputation: 1,235


Return to Construct 2 General

Who is online

Users browsing this forum: No registered users and 2 guests