View unanswered posts | View active topics It is currently Fri Aug 14, 2020 3:12 am



Reply to topic  [ 8 posts ] 
 Spawning multiple MOPixels and having multiple math.randoms 
Author Message
Data Realms Elite
Data Realms Elite
User avatar

Joined: Fri Jan 07, 2011 8:01 am
Posts: 6211
Location: In your office, earning your salary.
Reply with quote
Post 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.


Sun Aug 14, 2011 8:48 pm
Profile
Data Realms Elite
Data Realms Elite
User avatar

Joined: Fri Jan 07, 2011 8:01 am
Posts: 6211
Location: In your office, earning your salary.
Reply with quote
Post Re: Spawning multiple MOPixels and having multiple math.randoms
You are welcome.


Sun Aug 14, 2011 8:51 pm
Profile
happy carebear mom
User avatar

Joined: Tue Mar 04, 2008 1:40 am
Posts: 7094
Location: b8bbd5
Reply with quote
Post 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.


Mon Aug 15, 2011 5:05 pm
Profile
User avatar

Joined: Wed Feb 17, 2010 12:07 am
Posts: 1545
Location: That small peaceful place called Hell.
Reply with quote
Post 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)))


Mon Aug 15, 2011 6:10 pm
Profile
DRL Developer
DRL Developer
User avatar

Joined: Wed Dec 13, 2006 5:27 am
Posts: 3136
Location: A little south and a lot west of Moscow
Reply with quote
Post 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.


Mon Aug 15, 2011 10:35 pm
Profile WWW
User avatar

Joined: Wed Feb 17, 2010 12:07 am
Posts: 1545
Location: That small peaceful place called Hell.
Reply with quote
Post 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.


Mon Aug 15, 2011 11:10 pm
Profile
DRL Developer
DRL Developer
User avatar

Joined: Wed Dec 13, 2006 5:27 am
Posts: 3136
Location: A little south and a lot west of Moscow
Reply with quote
Post 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.


Mon Aug 15, 2011 11:35 pm
Profile WWW
REAL AMERICAN HERO
User avatar

Joined: Sat Jan 27, 2007 10:25 pm
Posts: 5655
Reply with quote
Post Re: Spawning multiple MOPixels and having multiple math.randoms
RadRotate(math.random() * (2*math.pi));

works great


Mon Aug 15, 2011 11:37 pm
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 8 posts ] 

Who is online

Users browsing this forum: Google [Bot]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by STSoftware for PTF.
[ Time : 0.013s | 14 Queries | GZIP : Off ]