|
Post by lifevirus on Feb 12, 2015 4:53:23 GMT
I'm having some trouble with a memory leak and I'm curious as to the maximum number of spawners a scene can have at any one point in time?
Now i'm guessing that i'm using too many but I've maxed it out at about 250-275 on one scene before hitting play causes a memory crash and force quits Unity. This is because the game I'm working on has waves that are elaborate and my boss doesn't want the enemies running into each other so we have each enemy independently spawning on a single spawner.
Would it be easier to just make a prefab that contains each group of enemies and link it to a single spawner or would a prefab pool with nudge and randomization would better? It's mostly about getting the waves to look realistic and not passing through each other while maintaining a low memory usage.
|
|
|
Post by DarkTonic Dev on Feb 12, 2015 5:05:02 GMT
I have no idea, but it would most likely depend on how much memory your computer has, how many different waves each spawner has, and how many things each are spawning all at once.
The memory crash could also simply be a problem you're having with some other plugin you're using just because you have so many "heavy" game objects. Such as Playmaker / Behavior Designer? I'm not sure what else you use besides Core GameKit. The things that are spawning have what sort of scripts on them? I had the same sort of problem, which turned out to be Behavior Designer unable to scale that many game objects.
I don't think only 250 spawners spawning really lightweight game objects would have much impact on performance or memory.
|
|
|
Post by lifevirus on Feb 19, 2015 5:54:44 GMT
Baring Playmaker script that act as animation control nothing much aside rigid bodies, box colliders and the Simple Waypoint System pathing that is attached to each enemy. Along with the updated UniBulletHell shot controller script, which works but has a odd issue where it creates a alternate pool that carries the bullets before sending them back to the main PoolBoss, and the normal CoreGame stuff.
Each group spawner (triggered spawner) has about 5-8 spawners (trigger spawners) spawning 1 enemy each. It's mostly about getting group to fly in pattern and not collide in air. Is that the possible reason? Would it be better to create a large prefab of the groups to minimize the number of spawners?
I also have pathing on each enemy that spawns as part of the prefab using the Simple Waypoint System.
So it's basically Parent Gameobject (Holds Killable and colliders and UniBulletHell) Sprite (2dToolkit and some Playmaker scripts for animation) Shadow (2dToolkit and some Playmaker Scripts for animation) Waypoint Finder (used with SWS as enemy movement) Gameobject (Used as firing position for bullets with UniBulletHell)
Some have multiple planes in the same prefab but no more than five.
I'm curious as to if it's the SWS but most of that doesn't start until the plane is actually activated. Any ideas?
|
|
|
Post by DarkTonic Dev on Feb 19, 2015 7:40:45 GMT
How many of the rigidbodies are "gravity"? A lot of those can have a huge impact on performance. If you're saying there is a Playmaker FSM on everything you're spawning I would bet money that is what's taking most of the performance. Playmaker doesn't scale well in my limited testing. Once I tried to spawn about 300 dead simple game objects with an FSM and Unity practically locked up.
Again, I don't think the number of spawners has much to do with your problem at all. It's most likely just the overhead of *some* script that's on the spawned things. You can experiment by removing the pathfinding and/or Playmaker stuff and see if it improves. Just to narrow down the problem. That's where I'd start.
If you have Unity pro, you can run a Profiling session and see which scripts are taking a lot of time. I would bet it's not CGK because it doesn't do much complex math or other slow operations.
|
|
|
Post by lifevirus on Feb 19, 2015 15:37:44 GMT
The only things that have gravity are the bullets since that's how the manual suggested it work as there'll be more of those then enemies. Would swapping it to all the enemies/players be the better option?
I'll look into playmaker/pathfinding and see if that causes any changes since I don't have Pro. I may have the 30 day trial, I'll check.
Thanks for the help.
|
|
|
Post by DarkTonic Dev on Feb 19, 2015 17:22:06 GMT
The only things that have gravity are the bullets since that's how the manual suggested it work as there'll be more of those then enemies. Would swapping it to all the enemies/players be the better option? Actually I believe it should be the other way around. You want the least amount of gravity Rigidbodies because each one costs some performance compared to kinematic.
|
|
|
Post by lifevirus on Feb 20, 2015 4:11:36 GMT
So I should keep the bullets gravity and have the enemies kinematic?
Sorry, if i'm being difficult here. Not sure what's the best for performance sake. The bullets are quicker to die and the enemies will be on longer so I'd assume the bullets having gravity is better since they are going to be in and out faster than the planes.
|
|
|
Post by DarkTonic Dev on Feb 20, 2015 4:17:53 GMT
I'm not sure either. I would try it both ways on a low powered device. See which one has better FPS. Your best guess is probably correct unless there are massive amounts of bullets on the screen at once, which might cause slowdown.
You can always do this later though.
|
|