Brutile Posted November 2, 2014 Share Posted November 2, 2014 My game so far consists of enemies spawning at random locations on a terrain. After testing half a dozen times, I've found that the game would consistently crash/stop responding after spawning exactly 130 enemies. I've also found that around the 80 mark, some enemies will be invincible. I've done all that I can to prevent memory leaks and after monitoring the memory usage, everything seems in order, but it still crashes after 130 enemies have spawned. Note that there are not 130 enemies alive at the same time, only 20 are allowed to be alive at once, and when they die, their entities and resources are released. Is this likely a fault with my code or is there something in the engine that is causing this? Quote Link to comment Share on other sites More sharing options...
AggrorJorn Posted November 2, 2014 Share Posted November 2, 2014 Without seeing code we can only guess. How do you spawn enemies? Quote Link to comment Share on other sites More sharing options...
Brutile Posted November 3, 2014 Author Share Posted November 3, 2014 Spawning script: In Start: enemyModel = Model:Load("Models/Characters/Crawler/crawler.mdl") enemyModel:Hide() Spawn Code: local enemy = Pivot:Create() enemy:SetScript("Scripts/Objects/AI/Enemy.lua") enemy.script.player = self.player enemy:SetPosition(Vec3(math.random(-1000, 1000), 1000, math.random(-1000,1000)), true) local pick = PickInfo() local p = enemy:GetPosition() --places enemy above the terrain if self.world:Pick(p, Vec3(0, 0, 0), pick, 0.0, true) then pick.position = pick.position + pick.normal enemy:SetPosition(pick.position) end Enemy Script: In Start: --makes an instance of the enemy model in the spawning script self.playerModel = enemyModel:Instance() self.playerModel:SetParent(self.entity) self.playerModel:SetPosition(Vec3(0)) self.playerModel:SetRotation(0, 180, 0) self.playerModel:SetScale(1.5, 1.5, 1.5) self.playerModel:Show() self.entity:SetMass(10) self.entity:SetPhysicsMode(Entity.CharacterPhysics) self.entity:SetCollisionType(Collision.Character) self.entity:SetPickMode(0) Let me know if there is anything else you want to see. 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.