Welcome, Guest
Want to take part in these discussions? Sign in if you have an account, or apply for one below
-
- CommentAuthorPhillip
- CommentTimeJul 16th 2008
Hi.
I'm trying to have a GravityWell pull my particles out of their ring shaped emitter towards a Jet that propells them in a certain direction. The Jet seems to have no effect what-so-ever. Can someone tell me what's going on? It appears that Jet isn't working at all (I'm using the most recent version 1.0.3) ...?
Here's the relevant code:
//[...] lots of the usual init-stuff here, as seen in the tutorial...
//A ring-shaped emitter:
var emitCenter:Point = new Point(originX, originY);
var innerRadius:Number = 20;
var outerRadius:Number = 30;
var emitterZone:DiscZone = new DiscZone(emitCenter, innerRadius, outerRadius);
var position:Position = new Position( emitterZone );
emitter.addInitializer( position );
//Building the jet accelerator, a circle with 70px diameter, which should cover the emitter perfectly:
var jetCenter:Point = new Point(originX, originY);
innerRadius = 0;
outerRadius = 70;
var jetZone:DiscZone = new DiscZone(jetCenter, innerRadius, outerRadius);
//--> Jet(accelerationX:Number, accelerationY:Number, zone:Zone) ... invertZone = false)
var jetLance:Jet = new Jet(100, 100, jetZone);
emitter.addAction(jetLance);
//We need a gravity well to pull the particles out of the ring-shaped emitter:
//--> GravityWell(power:Number , x:Number, y:Number, epsilon:Number = 100)
var gravCenter:GravityWell = new GravityWell(20, originX, originY, 100);
emitter.addAction(gravCenter);
//'Move' Action to move the particles
var move:Move = new Move();
emitter.addAction(move);
emitter.start();
As I mentioned, the GravityWell works fine. So does Explosion, ApproachNeighbor and all kinds of stuff. It's only Jet that doesn't work. Neither alone or in conjuction with others. Any help is appreciated.
Thanks.
Phillip -
- CommentAuthorRichard
- CommentTimeJul 16th 2008 edited
Hi Phillip
You have the innerRadius and outerRadius the wrong way around in the constructor of your DiscZones. It should bevar emitterZone:DiscZone = new DiscZone(emitCenter, outerRadius, innerRadius);
andvar jetZone:DiscZone = new DiscZone(jetCenter, outerRadius, innerRadius);
I defined the arguments in this order because the innerRadius has a default value (zero) but the outerRadius doesn't, so the innerRadius has to come later in the arguments list.
Obviously, this ordering is unexpected and hence your understandable error. I will add an error check to the code to ensure that outerRadius is not smaller than innerRadius and throw a meaningful error message if it is - that at least should indicate the error as soon as it occurs. -
- CommentAuthorPhillip
- CommentTimeJul 17th 2008
Hey, Richard.
Thanks. I would've never figured that out on my own. It's indeed a tricky one.
Thanks for the help. It's a very neat Particle Sytem btw, thank you for that too.
1 to 3 of 3
