Data Realms Fan Forums http://45.55.195.193/ |
|
Emitting only one particle instead of many http://45.55.195.193/viewtopic.php?f=73&t=31692 |
Page 1 of 1 |
Author: | Djinn [ Thu Sep 13, 2012 2:44 pm ] |
Post subject: | Emitting only one particle instead of many |
Back again with another question! This time I have something releasing seeds when it gets to a certain frame, which works as expected, except because of the way I did it the entire time it's on that frame it sprays them all over. I put an if statement there which constrains the seed creation appropriately - however, since the seeds create other instances of this, the variables seem to carry across to all of them. So one plant creates four seeds, but only one of the creates more seeds. While that's probably not bad balance-wise, that's not what I'm looking for. Is there a better way to make this emit only one than an if statement? For statements don't seem to work either. Code: function Create(self) self.minframe = 0; self.maxframe = 0; self.growthframe = 0; self.counter = 0; self.lifetimer = Timer(); stop = 0; end function Update(self) if self.Frame == 7 and stop == 0 then local seed = CreateMOSRotating("Missile Seedpod","Xenobiology.rte") seed.Pos = self.Pos + Vector(0,-20); seed.Vel = Vector(0 + math.random(-8,8),-40); seed.RotAngle = 0; MovableMan:AddParticle(seed) stop = 1 end if self.Frame >= 10 then self.ToSettle = true; end end |
Author: | Coops [ Thu Sep 13, 2012 4:35 pm ] |
Post subject: | Re: Emitting only one particle instead of many |
What do you mean for statements don't work? Something like this doesn't do it? Code: if self.Frame == 7 and stop == 0 then for i = 1, 4 do local seed = CreateMOSRotating("Missile Seedpod","Xenobiology.rte") seed.Pos = self.Pos + Vector(0,-20); seed.Vel = Vector(0 + math.random(-8,8),-40); seed.RotAngle = 0; MovableMan:AddParticle(seed) end stop = 1 end |
Author: | Shook [ Thu Sep 13, 2012 5:20 pm ] |
Post subject: | Re: Emitting only one particle instead of many |
Hypothesis 1: SEMICOLONS (they're missing after some lines, don't know if it's critical) Hypothesis 2: self. that stop variable up. As in, set it to "self.stop" instead of just "stop", since the latter can be called by any and every object in the scene. This might be what's hindering the other plants, since they see that "stop = 1", and thus do not spawn any additional seed pods. |
Author: | Djinn [ Thu Sep 13, 2012 9:49 pm ] |
Post subject: | Re: Emitting only one particle instead of many |
Shook wrote: Hypothesis 2: self. that stop variable up. As in, set it to "self.stop" instead of just "stop", since the latter can be called by any and every object in the scene. This might be what's hindering the other plants, since they see that "stop = 1", and thus do not spawn any additional seed pods. ....Yeeeeep. Forgot to put a self. there. I'm super embarassed, but hey, it works now! Thanks . |
Author: | Bad Boy [ Fri Sep 14, 2012 4:50 am ] |
Post subject: | Re: Emitting only one particle instead of many |
Shook wrote: Hypothesis 1: SEMICOLONS (they're missing after some lines, don't know if it's critical) Glad you got this sorted out Djinn. |
Page 1 of 1 | All times are UTC [ DST ] |
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group http://www.phpbb.com/ |