Objects not in view - affect perfromance?

Discussion and feedback on Construct 2

Post » Thu Feb 21, 2013 7:40 am

Simple question.

Do instances of objects that are not in the visible area degrade performance?

i.e. if I had 5000 instances but 4500 were no where in sight do they still get tested for collisions etc?
B
31
S
8
G
5
Posts: 436
Reputation: 5,836

Post » Thu Feb 21, 2013 1:27 pm

The answer is "Yes". This was addressed in the beginner's "top down shooter" tutorial, page 3 (Found here - https://www.scirra.com/tutorials/37/beginners-guide-to-construct-2/page-3)

Excerpt: "Destroy outside layout." Instead of stopping an object leaving the layout area, this destroys it if it does. It's useful for our bullets. Without it, bullets would fly off the screen forever, always taking a little bit of memory and processing power. Instead, we should destroy the bullets once they've left the layout.
B
4
Posts: 57
Reputation: 514

Post » Thu Feb 21, 2013 1:47 pm

See Performance Tips.

All objects, even if not on screen, still run the logic (events, collision detection, etc.) A lot of games would be broken if this didn't happen! However rendering is usually the bottleneck, so usually it's not important that offscreen objects are still doing that.

The beginner's guide tutorial's advice to destroy objects outside the layout is more to prevent a memory leak. If every bullet you ever fire is still active in the game, the game will gradually slow down and use more and more memory.
Scirra Founder
B
359
S
214
G
72
Posts: 22,949
Reputation: 178,544

Post » Thu Feb 21, 2013 2:36 pm

Thanks, that is what I wanted to know.

I have set it up that objects passing to the left of the viewport are destroyed.This product seems amazingly optimised.
B
31
S
8
G
5
Posts: 436
Reputation: 5,836

Post » Thu Feb 21, 2013 3:15 pm

@Ashley Is there any difference between an invisible object in the screen area,
and a visible object off screen for rendering?

Also, if an object is behind another (for example a large UI for the game), does this area get updated by the renderer?lemo2013-02-21 15:19:30
B
20
S
5
G
8
Posts: 325
Reputation: 6,473

Post » Thu Feb 21, 2013 4:46 pm

@lemo - invisible objects are identical to offscreen objects. C2 uses a back-to-front renderer, so objects underneath larger objects are still rendered.
Scirra Founder
B
359
S
214
G
72
Posts: 22,949
Reputation: 178,544

Post » Thu Feb 21, 2013 6:40 pm

Okay thx for the details!
B
20
S
5
G
8
Posts: 325
Reputation: 6,473

Post » Sat Nov 30, 2013 3:51 am

Sorry to relive an old topic, but something's been bothering me a little. I know it's a good practice to destroy objects like bullets when they leave the screen, but does it affect performance if I add the "destroy outside layout" behaviour to level objects, such as platforms, background trees and such? That's when making long, scrolling levels of course.
B
7
Posts: 28
Reputation: 335


Return to Construct 2 General

Who is online

Users browsing this forum: Eisenhans, humanescape and 14 guests