pixijs / particle-emitter

A particle system for PixiJS

Home Page:http://pixijs.io/particle-emitter/docs

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Set velocity direction separately from rotation

jkstrawn opened this issue · comments

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?

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.