Data Realms Fan Forums http://45.55.195.193/ |
|
Spawning multiple MOPixels and having multiple math.randoms http://45.55.195.193/viewtopic.php?f=73&t=25160 |
Page 1 of 1 |
Author: | Asklar [ Sun Aug 14, 2011 8:48 pm ] |
Post subject: | Re: Spawning multiple MOPixels and having multiple math.randoms |
If you place all the particle definition inside the for? I made a code which makes 10 rockets spawn and it works: Code: for G = 1, 10 do self.ExplosiveDamage = CreateAEmitter("Particle Beast Rocket") self.ExplosiveDamage.Pos = self.MuzzlePos self.ExplosiveDamage:SetWhichMOToNotHit(MovableMan:GetMOFromID(self.RootID),-1) self.ExplosiveDamage.Vel = Vector((25+(G*math.random(2)))*self.reverseNum,math.random(5)-(G/2)):RadRotate(self.RotAngle) MovableMan:AddParticle(self.ExplosiveDamage) end Then you just need to change the position to make it circle a point, like making a vector and rotate acording to the G (in your script the i) value. |
Author: | Asklar [ Sun Aug 14, 2011 8:51 pm ] |
Post subject: | Re: Spawning multiple MOPixels and having multiple math.randoms |
You are welcome. |
Author: | Duh102 [ Mon Aug 15, 2011 5:05 pm ] |
Post subject: | Re: Spawning multiple MOPixels and having multiple math.randoms |
I dunno if that means you figured it out entirely or not, but in case you haven't, use math.sin and math.cos. Code: particle.Pos = Vector(math.sin(math.random(-math.pi, math.pi)) * (radius) + (pointx), math.cos(math.random(-math.pi, math.pi)) * (radius) + (pointy)) Insert values or variables for pointx, pointy, and radius. Also check my parens, I might have messed them up. Also you might need to swap sin and cos, I can never remember if the x coord uses sin or cos. EDIT: Oh, and this goes in your for loop, as does everything when defining your particle. Each runthrough of the for should define a new particle, define it's position, then add it to MovableMan. |
Author: | Coops [ Mon Aug 15, 2011 6:10 pm ] |
Post subject: | Re: Spawning multiple MOPixels and having multiple math.randoms |
If I'm reading this right, you want several MOPixels to spawn at a point in a circular formation? How come I never see people do something like this? Code: self.pixel.Pos = self.yourpoint.Pos + Vector(your diameter,0):RadRotate(math.rad(math.random(360))) |
Author: | TheLastBanana [ Mon Aug 15, 2011 10:35 pm ] |
Post subject: | Re: Spawning multiple MOPixels and having multiple math.randoms |
Coops, that works, but replace the "360" with "math.pi * 2". You're rotating in radians, not degrees. |
Author: | Coops [ Mon Aug 15, 2011 11:10 pm ] |
Post subject: | Re: Spawning multiple MOPixels and having multiple math.randoms |
The description for math.rad is: Code: Converts a number from degrees to radians. I figured converting 360 degrees to radians is the same thing. |
Author: | TheLastBanana [ Mon Aug 15, 2011 11:35 pm ] |
Post subject: | Re: Spawning multiple MOPixels and having multiple math.randoms |
Oh, whoops, I missed the math.rad. Probably easier to just give it 2 * math.pi instead of converting it, though. |
Author: | Grif [ Mon Aug 15, 2011 11:37 pm ] |
Post subject: | Re: Spawning multiple MOPixels and having multiple math.randoms |
RadRotate(math.random() * (2*math.pi)); works great |
Page 1 of 1 | All times are UTC [ DST ] |
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group http://www.phpbb.com/ |