PathFollower moving speed is not consistent (Not linear)

Hi there

I want to create a zuma like game using PathFollower, but I have a problem related to it’s movement (Linear), on some areas / line, the ball get faster or slower, that causing ball spacing or the ball is overlapping each other.

Here is the illustration:

Untitled

I also try using Rex Path follower plugin/behavior, but the result is same

How to fix it ?

What’s the code?

Here is the code

for(let i=0; i<15; i++){
			let ball = this.physics.add.sprite(0, 0, 'ball');
			ball.setInteractive();
			ball.body.setCircle(32);
			ball.setInteractive();
			ball.id = i;
			balls.push(ball);
		}
		balls.forEach((ball)=>{
			ball.pathFollower = self.plugins.get('rexpathfollowerplugin').add(ball, {
				path: curve,
				t: 0,
				rotateToPath: true
			});
			self.tweens.add({
			targets: ball.pathFollower,
				t: 1,
				ease: 'Linear', // 'Cubic', 'Elastic', 'Bounce', 'Back'
				duration: speed,
				repeat: -1,
				yoyo: false,
				delay: 170*ball.id,
			});
		});

Built-in path follower game object and my path follower behavior both use curve.getPoint(t) to get position from t. The spacing between points are not equal. See this demo
圖片

Add spacedPoints parameter in configuration object of rexPathFollower plugin, which uses curve.getSpacedPoints(divisions, stepRate) to get points.

See this demo, line 47-49.
Path follower at right side uses spacedPoints, the moving speed would be more consistent.

Please download rexpathfollowerplugin.min.js to get this new feature.

1 Like

Thank you!