I tried implementing liquid but now it gives me weird effects like:

- Jittering

- Condensing into one layer or ball

- etc

var b:LiquidBall; var b2:LiquidBall var visibleRadius:Number = ballRadius * 1.25; for each ( b in balls ) { //gravity if ( b.v.y < 10 ) { b.v.y += gravity; } b.v.x += -player.speed * .25; // border collision if ( b.y + b.v.y + visibleRadius >= liquidCore.height - 1 ) { b.v.y = 0; b.y = liquidCore.height - visibleRadius - 1; } else if ( b.y + b.v.y - visibleRadius <= 1 ) { b.v.y = -b.v.y b.y = 1 + visibleRadius } if ( b.x + b.v.x + visibleRadius >= liquidCore.width - 1 ) { b.v.x = -b.v.x * .2; b.x = liquidCore.width - 1 - visibleRadius; } else if ( b.x + b.v.x - visibleRadius <= 1 ) { b.v.x = -b.v.x * .2; b.x = 1 + visibleRadius; } //ball to ball collision for each ( b2 in balls ) { if ( b != b2 ) { var d:Number = dist( b.x, b.y, b2.x, b2.y ) var dx:Number = b2.x - b.x; var dy:Number = b2.y - b.y; if ( d <= ballRadius * 1.5 ) { b.v.x = -dx * .1; b.v.y = -dy * .1; } } } b.x += b.v.x; b.y += b.v.y; //rendering liquidData.copyPixels( baseBallData, baseBallData.rect, new Point( b.x - ballRadius, b.y - ballRadius ), null, null, true ); }

Is there something I should be doing differently?