Spawning too many units causing lag

Status
Not open for further replies.
Level 14
Joined
Aug 30, 2004
Messages
909
I am using a custom unit to represent a heat seeking rocket so I can move it about the map and have it follow it's target.

The problem: I potentially spawn many of these at a time, up to 30 or 40. When that happens the game lags substantially.

I really can't use the standard user interface for my weapon systems and I'm afraid this will mean GAME OVER for the map if I can't solve this problem.

Are there any solutions here?

Could I store all the missiles in an unused hidden area and just move and unhide them? Can I preload them somehow?

/await nervously

Darwin
 
Level 14
Joined
Aug 30, 2004
Messages
909
Maybe show use the triggers/code of your missile system?

I'd like to, but it's very complicated across many other triggers. Basically, 3 units are ordered to "roar" every .1 seconds for about 1 second. Each time they do I create a new unit (a rocket). So I spawn 3 units every .1 seconds for 1 second, or 30 units in a second.

Spawning too many units does cause lag, no? I'm just looking for solutions to it.
 
Level 3
Joined
Jul 4, 2010
Messages
34
The best solution would be to limit the amount of missiles to a certain amount... say, 10

Then you would make a series of triggers and variables like:

Variable: AmountOfMissles set to 0

And in your spawn trigger set AmountOfMissles = AmountOfMissles + 1
Then on Death set it -1

and a third trigger:


  • Example
  • Every .01 seconds of the game
  • AmountOfMissles >= 10
  • Turn off Missle Spawn
or add an if/then/else to the spawn and:



  • Example
  • if: AmountOfMissles < 10
  • then: (your spawning actions)
  • else: turn off (this trigger)
  • message auto timed (you have too many missles out on the map)
Thats the simple solution :p
 
Level 14
Joined
Aug 30, 2004
Messages
909
I might have to settle for something like that, but that will severly limit game play. it's a multi-player map with up to 5v5. I could scroll that back to 3v3 and live with myself, but then there's computer AI as well...

I'm happy for a complicated solution if you have something in mind. I'm pretty skilled with the GUI, so you don't have to give me all the details, just a plan of attack if you have one.

In other words, that's the short solution, but what's the long one?

When the rockets die, would it be faster to move them somewhere, resurrect them, and reuse them?

Where is the source of the lag? Is it in making the unit's stats? In rendering the model?


The best solution would be to limit the amount of missiles to a certain amount... say, 10

Then you would make a series of triggers and variables like:

Variable: AmountOfMissles set to 0

And in your spawn trigger set AmountOfMissles = AmountOfMissles + 1
Then on Death set it -1

and a third trigger:


  • Example
  • Every .01 seconds of the game
  • AmountOfMissles >= 10
  • Turn off Missle Spawn
or add an if/then/else to the spawn and:



  • Example
  • if: AmountOfMissles < 10
  • then: (your spawning actions)
  • else: turn off (this trigger)
  • message auto timed (you have too many missles out on the map)
Thats the simple solution :p
 
Level 10
Joined
Jan 21, 2007
Messages
576
Your best option is recycling the units. When the missile hits or w/e it does when you normally remove it, instead move it somewhere for safekeeping and have a way to reference it (putting it in a group for example).

Then when you need a missile to be 'created' check if there is a missile in the group and use it, if not then create one. You might want to create like 50 missiles right at the start so there is no lag the first time someone tries to shoot/cast.
 
Level 4
Joined
Jul 23, 2008
Messages
99
Have you know that unit costs a lot of memory? Then, you use it massively in a short period... That was not a good idea.

Maybe you should change the spell concept or change the unit to moving SFX.
 
Level 14
Joined
Aug 30, 2004
Messages
909
Have you know that unit costs a lot of memory? Then, you use it massively in a short period... That was not a good idea.

Maybe you should change the spell concept or change the unit to moving SFX.

I would love to make them moving special effects. I didn't think this was possible. I've never seen an action that let's you move a special effect if it's not attached to a unit.

Champara, checking your map now, thanks!
 
Status
Not open for further replies.
Top