Slastraf Posted November 2, 2015 Share Posted November 2, 2015 http://www.mediafire.com/download/dm6d64ri0476tz5/WinRARbySlastraf.rar Above a link to my project (~40 mb) In the start map there is a folder in the scene editor called spawners. there are some spawners and a spawncontroller. the spawners themsleves are able to spawn crawlers into the scene, the spawncontroller is able to increase the maximum amount of enemies in the scene every new round. My problem is that there are still spawning crawlers and i dont know why, The method SpawnEnemy() in the zombiespawner script doesnt get triggered nowhere and i am very confused. Thanks for reading and helping Friedrich Pm: textures are missing for small download size Quote Link to comment Share on other sites More sharing options...
Einlander Posted November 2, 2015 Share Posted November 2, 2015 Figured it out. You loaded the prefabs of the zombies when you start the script (lines 11 and 12). So when you start the game, every spawner spawns 2 crawlers. This should be in the SpawnEnemy function so only when it called they are spawned. Quote Link to comment Share on other sites More sharing options...
Slastraf Posted November 3, 2015 Author Share Posted November 3, 2015 Figured it out. You loaded the prefabs of the zombies when you start the script (lines 11 and 12). So when you start the game, every spawner spawns 2 crawlers. This should be in the SpawnEnemy function so only when it called they are spawned. I had that before, but it affects the frames very much. When the spawnEnemy function is called, it loads it once again, even if not necessary. Quote Link to comment Share on other sites More sharing options...
Rick Posted November 3, 2015 Share Posted November 3, 2015 In ZombiesSawner.lua you are loading 2 zombie prefabs: if self.zombie==nil then self.zombie= Prefab:Load("Prefabs/Characters/crawler1.pfb")end if self.zombie2==nil then self.zombie2 = Prefab:Load("Prefabs/Characters/orangecrawler.pfb")end You aren't setting the positions to the spawner positions so they are all spawning at 0,0,0 and running toward the turret. Because you have 6 spawners you get 12 zombies right away. I think you are running into an issue where you need to preload 1 zombie prefab and always keep it in your scene but disable it. That way other loads will load instances of the same one which will be basically instant. If you don't have any instances of a model and then you load it during run-time it'll pause your game. If you load an instance and then kill/release them and another one loads, most likely is what happens as you are killing zombies in a tower defense game, then you'd get this pause often. I think your best bet is to manually drag the zombie model (just the model) into your scene and drag it under the terrain and make sure it doesn't have mass so it just floats there. That will be your precache loading and now all loading of that prefab, it's the model and textures themselves that take up loading time and pause your game, will be near instant. Note this will be common practice for dynamic things in all your games. You always want to load 1 of said model at the start, most likely just drag it in at design time, and keep it loaded throughout the game so subsequent loads will be instant and not affect your FPS. 1 Quote Link to comment Share on other sites More sharing options...
Thirsty Panther Posted November 3, 2015 Share Posted November 3, 2015 Here is a nice video explaining this concept by Bluhornet. Quote Link to comment Share on other sites More sharing options...
Slastraf Posted November 3, 2015 Author Share Posted November 3, 2015 I watched it some time ago. The problems I have in my game right now are deeper , and its not the performance.I got told to make this thread with an explanation and the project because this person couldnt help me at this point , too. Quote Link to comment Share on other sites More sharing options...
Slastraf Posted November 4, 2015 Author Share Posted November 4, 2015 I watched it some time ago. The problems I have in my game right now are deeper , and its not the performance.I got told to make this thread with an explanation and the project because this person couldnt help me at this point , too. Explained in a new thread Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.