Particle spawn radius

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
User avatar
VideroBoy
Party member
Posts: 102
Joined: Wed Mar 31, 2010 6:12 pm
Location: Canada

Particle spawn radius

Post by VideroBoy »

Right now a particle emitter shoots all particles out of its exact coordinate.

How would I go about making the particles look like they spawn anywhere within some radius around the coordinate.

I'm trying to create some kind of comet effect around a sprite, where there's a halo of particles surrounding the sprite with the ones behind trailing off. All my experiments end up with the particles either going too fast, going too far, or traveling in a cone behind the sprite with no particles in front.
User avatar
knorke
Party member
Posts: 239
Joined: Wed Jul 14, 2010 7:06 pm
Contact:

Re: Particle spawn radius

Post by knorke »

Right now a particle emitter shoots all particles out of its exact coordinate.
I think that can not be changed.

You could move around the particle emiter using ParticleSystem:setPosition (x, y)

ie to spawn in a a=100 square around the center:
ParticleSystem:setPosition (x+math.random(-50,50) , y+math.random(-50,50))

or to spawn in a ring with r=100 around the center:
local angle = math.random (0, 3.14 * 2)
local r = 100
ParticleSystem:setPosition (x + sin (angle) *r, y +cos (angle) *r)
User avatar
VideroBoy
Party member
Posts: 102
Joined: Wed Mar 31, 2010 6:12 pm
Location: Canada

Re: Particle spawn radius

Post by VideroBoy »

So instead of having an emitter in the centre, I could have a ring of emitters around the centre at the desired radius. I guess that could work.
User avatar
TechnoCat
Inner party member
Posts: 1611
Joined: Thu Jul 30, 2009 12:31 am
Location: Denver, CO
Contact:

Re: Particle spawn radius

Post by TechnoCat »

VideroBoy wrote:So instead of having an emitter in the centre, I could have a ring of emitters around the centre at the desired radius. I guess that could work.
I believe he was actually suggesting you move the emitter around randomly.
User avatar
tentus
Inner party member
Posts: 1060
Joined: Sun Oct 31, 2010 7:56 pm
Location: Appalachia
Contact:

Re: Particle spawn radius

Post by tentus »

Think of the emitter like a water hose. You can change the hose's angle and flow etc, but to have multiple starting locations you'll need to shake the hose around.
Kurosuke needs beta testers
User avatar
VideroBoy
Party member
Posts: 102
Joined: Wed Mar 31, 2010 6:12 pm
Location: Canada

Re: Particle spawn radius

Post by VideroBoy »

TechnoCat wrote:I believe he was actually suggesting you move the emitter around randomly.
This is what I ended up implementing. It's good enough.
Post Reply

Who is online

Users browsing this forum: Google [Bot] and 237 guests