rons0n Posted July 13, 2015 Share Posted July 13, 2015 I want a particular item of mine to spawn another item at a specific time range but something is off? I thought this would work: inst:AddComponent("periodicspawner") inst.components.periodicspawner:SetPrefab("balloon") inst.components.periodicspawner:SetRandomTimes(2, 4) inst.components.periodicspawner:SetDensityInRange(20, 2) inst.components.periodicspawner:SetMinimumSpacing(8) inst.components.periodicspawner:Start()But it isn't working as I thought it would. When I make this particular item it does spawn the balloon but only once. The only way it can spawn another balloon is by attacking the balloon. But then I decided to make the same particular item and that same item doesn't spawn the balloon, but after attacking the balloon of the first particular item the second same item spawns the balloon instead not the first. And this goes on for each copy of the doll I've made. How do I bypass this? Link to comment https://forums.kleientertainment.com/forums/topic/56145-how-does-periodic-spawner-works/ Share on other sites More sharing options...
rezecib Posted July 14, 2015 Share Posted July 14, 2015 @rons0n, It looks from this block that your minimum spacing specification may be messing things up: if canspawn and (self.range or self.spacing) then local pos = Vector3(self.inst.Transform:GetWorldPosition()) local ents = TheSim:FindEntities(pos.x,pos.y,pos.z, self.range or self.spacing) local count = 0 for k,v in pairs(ents) do if v.prefab == prefab then if self.spacing and v:GetDistanceSqToInst(self.inst) < self.spacing*self.spacing then canspawn = false break end count = count + 1 end end if self.density and count >= self.density then canspawn = false end endDoes it work if you remove SetMinimumSpacing? According to that block, it won't spawn a new entity if there's already one within the minimum spacing. Link to comment https://forums.kleientertainment.com/forums/topic/56145-how-does-periodic-spawner-works/#findComment-654123 Share on other sites More sharing options...
rons0n Posted July 14, 2015 Author Share Posted July 14, 2015 @rezecib, Thanks, you are most definitely correct. Removing the SetMinimumSpacing has had me spawn balloons galore. Well by galore I mean only 2 balloons. Turns out there was a second culprit, inst.components.periodicspawner:SetDensityInRange(20, 2) But I dont understand still, why does it spawn 2 but not 20 as its shown in that line?Same goes for SetRandomTimes where it'll spawn a new one every 4 seconds but not 2. Am I missing something here? Link to comment https://forums.kleientertainment.com/forums/topic/56145-how-does-periodic-spawner-works/#findComment-654130 Share on other sites More sharing options...
rezecib Posted July 14, 2015 Share Posted July 14, 2015 @rons0n, The first argument is the range, the second is the density The arguments for the other one: SetRandomTimes(basetime, variance, no_reset). So you currently have it configured to spawn every 2-6 (2+4) seconds. Link to comment https://forums.kleientertainment.com/forums/topic/56145-how-does-periodic-spawner-works/#findComment-654157 Share on other sites More sharing options...
rons0n Posted July 14, 2015 Author Share Posted July 14, 2015 @rezecib, Thanks for the clarification! Time to spam servers with balloons! WooHoo! Link to comment https://forums.kleientertainment.com/forums/topic/56145-how-does-periodic-spawner-works/#findComment-654161 Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now