Path line stop

var path = new Phaser.Curves.Path(50, 500);

path.lineTo(500, 500);
path.lineTo(500, 100);
path.lineTo(50, 100);
path.lineTo(50, 500);

var graphics = this.add.graphics();

graphics.lineStyle(5, 0x00000, 5);

var enemy = this.add.follower(path, 50, 500, 'enemy').setScale(2, 2)

this.physics.add.existing(enemy).body.setSize(15, 20, false);

enemy.startFollow({
  duration: 30000,
  loop: -1,
  onLoop() {
  enemy.flipX = false
}

});

Is there any way to check if the follower has finished traversing a line? I want him to stop every time he finishes walking a line before going to the next

You could probably check if the path tween (https://photonstorm.github.io/phaser3-docs/Phaser.GameObjects.PathFollower.html#pathTween__anchor) is finished. I’m not sure the best way to do that, but I’ve done it by checking its progress(https://photonstorm.github.io/phaser3-docs/Phaser.Tweens.Tween.html#progress__anchor) or you could listen to the Events.TWEEN_COMPLETE event from the tween.

1 Like

1 Like