Game Development Community

schedules && performance

by Kevin James · in Torque Game Builder · 05/11/2010 (5:09 am) · 4 replies

My game is coming along nicely. I should have something to post here next week sometime. However, during my play-testing when the game is advanced and there is activity in most of the off-screen areas, the performance grinds to a halt and the game is unplayable. The activity is on the order of about 9 areas with an average of 10 AI units doing their thing in each area. So, lets say about 100 units acting simultaneously. Each unit fires off about 10 continuous schedules. The scheduled function looks like this:

function AlienMissile::Expired(%this)
{
   %this.safeDelete();
}

This gives the enemy a nice effect with range control (based on time of schedule). Is 1000 concurrent schedules too many?

About the author

Computer security, digital forensics, and platform jumper enthusiast. shells.myw3b.net/~syreal/


#1
05/11/2010 (8:20 am)
It's hard to know exactly what would cause the slowdown, but that many schedules could cause a problem.

In the past, when I've had hundreds of similar items on the screen, I add them to a SimSet. I then put a schedule on the SimSet to process all of the items in its list.

This requires a few changes. For example, you might need to assign an "expiredTime" on the missile so that the SimSet schedule can quickly determine if an object should be deleted. You may need to make other code changes to process the list more quickly, too.
#2
05/11/2010 (9:20 am)
That's a great suggestion! Coincidentally, I just spent a couple hours reworking the code with a simset of missiles for each alien. This allows me to limit the number issued which has helped noticeably. I can now have up to 12 busy areas and the game is still playable.

Next, I tried putting them in a "cycle" so that they would only get created once and set invisible rather than deleted. I got that working but it was worse for performance than just creating/deleting on the fly (big surprise to me).

I'll see if I can get a simset schedule working next. Thanks William!
#3
05/11/2010 (10:34 am)
That surprises me, too, that creating/deleting works better. It's not too big of a deal, though, if it's working as is.

I added classes/superclasses to the SimSet in 1.7.5. If you are using 1.7.5, you can create your SimSets with a class (say, MissileList) and have the schedules use common code that way.
#4
05/11/2010 (10:53 am)
I'm on 1.7.4. I'll wait for the dust to settle on 1.7.5 then take advantage of your SimSet upgrade.