-
Notifications
You must be signed in to change notification settings - Fork 130
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
PathParticle throws "TypeError: this.next is null" when speed has no interpolation #129
Comments
I also noticed that PathParticle ignores acceleration. But this may be expected behavior. However adding acceleration support for PathParticle could be easy (this is tested and works): // PathParticle.update()
// ...
if(this._doSpeed) {
const speed = this.speedList.interpolate(lerp) * this.speedMultiplier;
this.movement += speed * delta;
} else {
// Adapted from Particle.update()
if (this._doAcceleration) {
this.velocity.x += this.acceleration.x * delta;
this.velocity.y += this.acceleration.y * delta;
if (this.maxSpeed) {
var currentSpeed = ParticleUtils.length(this.velocity);
if (currentSpeed > this.maxSpeed) {
ParticleUtils.scaleBy(this.velocity, this.maxSpeed / currentSpeed);
}
}
}
const speed = ParticleUtils.length(this.velocity);
this.movement += speed * delta;
}
// ... Maybe open a feature request for it? |
Ignoring acceleration is intentional - PathParticles are supposed to move in an exact path, and being affected by gravity/wind would interfere with that. Merely changing |
Background
It took me a while to get the ParticlePath working, but following the example code I finally got it, with one exception: when I had the speed set to no interpolation (ie start speed = end speed) I got an error "TypeError: this.next is null".
How to reproduce
Solution
I've debugged the code enough to understand the cause. In PathParticle here: https://github.com/pixijs/pixi-particles/blob/master/src/PathParticle.ts#L153, the code assumes speedList needs to be interpolated. I think the solution involves first checking if
this._doSpeed
is true. If I understand PathParticle correctly the fix should look something like this:EDIT: Workaround
For anyone seeing this issue and needing a workaround (providing this isn't closed yet), I recommend setting speed start and end to nearly the same value, for example:
I'll get a PR started
The text was updated successfully, but these errors were encountered: