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

 Page 1 of 1 [ 8 posts ]
 Print view Previous topic | Next topic
Spawning multiple MOPixels and having multiple math.randoms
Author Message
Data Realms Elite

Joined: Fri Jan 07, 2011 8:01 am
Posts: 6211
Location: In your office, earning your salary.
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)
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
Data Realms Elite

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

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

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

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

Mon Aug 15, 2011 6:10 pm
DRL Developer

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

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

Joined: Wed Dec 13, 2006 5:27 am
Posts: 3136
Location: A little south and a lot west of Moscow
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
REAL AMERICAN HERO

Joined: Sat Jan 27, 2007 10:25 pm
Posts: 5655
Re: Spawning multiple MOPixels and having multiple math.randoms

works great

Mon Aug 15, 2011 11:37 pm
Display posts from previous:  Sort by
 Page 1 of 1 [ 8 posts ]

#### Who is online

Users browsing this forum: No registered users

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

Search for:
 Jump to:  Select a forum ------------------ Cortex Command    Dev Log    Wiki    Game Discussion    Game and Licensing Support    Mod Making       Lua Scripting       Requests    Mod Releases       Older Mods    Scene Releases       Scene Making Planetoid Pioneers    Game Discussion    Pioneer Program Lounge Data Realms Off-Topic    Off Topic Chat       Gaming       Forum Games    Site Support & Feedback
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by STSoftware for PTF.
[ Time : 0.016s | 14 Queries | GZIP : Off ]