pixijs / particle-emitter

A particle system for PixiJS
http://pixijs.io/particle-emitter/docs
MIT License
784 stars 124 forks source link

Set velocity direction separately from rotation #214

Open jkstrawn opened 2 months ago

jkstrawn commented 2 months ago

I'm trying to create particles that float straight up, with each particle having a random static rotation. It seems like a fairly straightforward situation. I've tried a lot of different behavior combinations but as far as I can tell this isn't possible - because the speed behavior relies on rotation for setting its direction. Is that correct?

andrewstart commented 2 months ago

That is correct. The Path, Speed, and Acceleration movement behaviors rely on the initial rotation to pick their direction. The simplest solution would probably be to make some sort of "ExtraLateStaticRotationBehavior" (that you may or may not use in combination with a regular rotation behavior) to set the rotation after it has been read by your movement initialization. Make a copy (or subclass) of StaticRotationBehavior and set its order to BehaviorOrder.Late + 1 (or 6), and register it on Emitter. The NoRotationBehavior does this exactly, but uses a defined rotation instead of a random rotation.