Disabled Groups taking CPU?

Discussion and feedback on Construct 2

Post » Sun Apr 09, 2017 9:00 pm

I have code that disables enemy groups that aren't being used (I'm checking if the SpawnEnemy.UID exists for each enemy, and then if it does NOT, it disables the group). However when I look at the debugger, it's still taking up ~0.2% cpu. I know that doesn't sound like a lot, but I have probably ~30 enemies and will likely have 30 more soon, so it's starting to add up. Is there a better way I should be doing this?
B
42
S
12
G
1
Posts: 540
Reputation: 4,213

Post » Sun Apr 09, 2017 9:31 pm

Don't you think it's the "enabled" enemies that are taking up more cpu than the dormant ones?

Either case you might want to create a destroy and create system where you destroy objects outside the viewport and re-create instances at their respective spots.

Are you using mutiple spawners in your layout? If so you can destroy enemy when exiting layout and save its respective properties (health, magic...) in its spawner and only destroy the spawner as well if the enemy reaches 0 HP. This way, you don't end up with some annoying respawning like in Ninja Gaiden.
Image Image Image
B
32
S
12
G
27
Posts: 761
Reputation: 17,244

Post » Sun Apr 09, 2017 11:55 pm

@MPPlantOfficial - no there are only ~3-4 active enemies per layout, and those are still only pulling 0.2-0.3% each. I'm beginning to think it's not actually disabling the group for some reason. It's calling the enable / disable group at the start of layout only, too.

My hierarchy is "if enemyspawn.UID exists, For each enemyspawn, create enemy"

Else

Disable group
Last edited by ome6a1717 on Mon Apr 10, 2017 12:05 am, edited 1 time in total.
B
42
S
12
G
1
Posts: 540
Reputation: 4,213

Post » Mon Apr 10, 2017 12:04 am

If uid exists doesn't sound right. As well as the for each.
Image ImageImage
B
170
S
50
G
179
Posts: 8,378
Reputation: 113,425

Post » Mon Apr 10, 2017 12:07 am

@newt - the for each is due to multiple instances of the same enemy type. The UID check is to find out if that enemy exists in the layout.

What would you suggest?
B
42
S
12
G
1
Posts: 540
Reputation: 4,213

Post » Mon Apr 10, 2017 12:17 am

enemyspawn.count
Image ImageImage
B
170
S
50
G
179
Posts: 8,378
Reputation: 113,425

Post » Mon Apr 10, 2017 1:16 am

@newt - yeah as usual that's a better idea :). I'll give it a try. Thanks!
B
42
S
12
G
1
Posts: 540
Reputation: 4,213


Return to Construct 2 General

Who is online

Users browsing this forum: newt and 5 guests