My game is left-right action TD, divided into 3 stages, with each stage has 10 Quests.
obviously each quest has different waves of enemies.
NOW I have the enemies stored in an array, then summon them 1 by 1 with 1~5secs delay.
but it seems that every enemy spawned will cause lag, and I can’t custom the spawn.
it will get really easy if the player lucky enough to get 5sec delay each spawn, and really hard if 1sec delay.
so I wanna change the approach.
What I have in mind is making 30 scenes for 30 Quests, so I can custom the difficulty.
and it looks like it will not cause lag upon spawning cos all the object loaded on scene start,
but the scene is longer to load, and I’m not using unity Pro, so the loading screen is really lame.
and wanna ask, if now I have 3scenes, and want to change to 30scenes, will it cause the apk size “much” bigger?
now my final apk size is 48MB, and all assets are completed.
will 30 scenes make it to 70ish MB?
Wow thanks… Never heard of this. tbh I just started gamedev 4months ago.
I’ve searched and learn what object pooling from this page
so basically, you put everything in scene or spawn everything on start instead of Instantiating overtime, change “destroy” to “deactivate”, and when u need to spawn just set the position to spawner and activate again.
that would work with some TD / Survival / Running / etc genres that randomize the entire spawn.
and if you read my post above, I want to set the enemy waves myself to make the game more strategic, and players can grind or memorize that stage as they get failed continuously, and come up with better team formation and equipments. (if u play Com2uS’ Brave Heroes u should know)
FYI, there will be 60+ enemies in a stage (late game) with about 5-8 respawning of each object (Bosses are not respawning tho)
you can see the scene sample is like this. image
so, will object pooling works for this kind of game?
if no, then Deactivating the killed enemy will be more performance friendly right?
May i ask to see the scripts attached in your “enemies” and the script you use to spawn them!?
We can give you a position of what is the problem by looking at your code.
Looking at your diagram, it looks very similar to the way I have designed my game.
All the gameobjects for each level are placed in the scene at the start when the level starts and are then made inactive.
I have an activator gameobject in front of camera direction of travel, and a deactivator object behind it. So as the camera moves from left to right the objects in the level are activated just before they come onscreen, and then deactivated after they pass off the back of the screen (unless they are deactivated by other means beforehand).
that “array of enemies” was my first approach and I don’t like it. then the image attached is the new approach i’m trying to do.
so maybe it’s a “NO” for object pool approach?
actually I use PlayMaker for the player and enemy controller. but maybe much less like this.
(not too familiar with Update codes)
void Update(){
transform.Translate(-5 * Time.deltaTime,0,0);
if(transform.position.x < manager.frontPlayerPos)
{
//I have 3 controllable characters here, so I update each position to manager object
//and check the largest one. I was first using TriggerEnter but that was horrible for performance
animator.setTrigger("Attack");
}
}
and for the spawner I’m using coroutines like in the 2D sample project.
they just keep instantiating from an object’s position within 1-3secs, and then walk left till it meets the character and attacks.
the spawn stops after it reach Enemies.Length();
besides I’m not using spawn system anymore. I’ve changed to my new approach.
haha what a funny game. I should try that approach
I can give you a hand in playmaker. I have it too. but most of things i don’t use it, because it is limited (or would have alots of nodes to approach what I want). I don’t see the why every spawn is causing lag.
Post a printscreen of your visual-script or PM-me (I can help you using skype).