Velocity of a path follower?

I’m trying to find the velocity of a path follower so I can properly lead a shot at it from a static tower. When I log the body.velocity of the closest path follower I get initialize {x:0, y:0}. Do path followers have velocity? I’m not sure where I’m going wrong here. Also does anyone have any suggestions on methods or approaches to properly leading a shot at a moving target in phaser? Thanks in advance!

``````class Game {
}

create() {
//map
const map = this.make.tilemap({ key: 'tilemap' })
map.createLayer('floor', tileset)
map.createLayer('walls', tileset)

//sprites
this.tower = this.physics.add.sprite( 200, 100, 'tower')
this.tower.setScale(3)

//create physics groups

//shoot count
this.nextTic = 0

//creates the path followers
delay: 3000,
callback: () => {
this.createLittleFella()
},
repeat: 0,
})
}

update() {
if(this.time.now > this.nextTic) {
this.fireCannon();
this.nextTic = this.time.now + 500;
}
}

createLittleFella = function(count) {
let path = new Phaser.Curves.Path(-40, 32)

path.lineTo(-40, 32)
path.lineTo(45, 32)
path.lineTo(45, 465) //518
path.lineTo(160, 465) //633
path.lineTo(160, 385) //713
path.lineTo(110, 385) //753
path.lineTo(110, 270) //868
path.lineTo(240, 270) //998
path.lineTo(240, 370) //1098
path.lineTo(305, 370) //1163
path.lineTo(305, 45) //1488
path.lineTo(450, 45) //1633
path.lineTo(450, 465) //2053
path.lineTo(530, 465) //2133 <-- if total in ten seconds velocity would be 213.3 pixels per second?

let mover = this.add.follower(path, -40, 32, 'littleFella');

mover.startFollow({
positionOnPath: true,
duration: 10000,
yoyo: false,
repeat: 0,
rotateToPath: false,
});

// coordinates [-40, 32, 45, 32, 45, 465, 160, 465, 160, 385, 110, 385, 110, 270, 240, 270, 240, 370, 305, 370, 305, 45, 450, 45, 450, 465, 530, 465 ]
delay: 10500,
callback: () => {
mover.destroy()
},
loop: false,
})
}

fireCannon = function(x, y, angle) {
let inRangeEnemy = this.closestEnemy(2000)
if (inRangeEnemy) {
let cannonBall = this.physics.add.sprite( 200, 100, 'cannonBall')
let angle = Phaser.Math.Angle.Between(200, 100, inRangeEnemy.x, inRangeEnemy.y);
const velocityFromAngle = this.physics.velocityFromAngle(angle, 2000, cannonBall.body.velocity)
}
}

closestEnemy = function(distance) {
var enemyUnits = this.enemies.getChildren();
if (enemyUnits) {
for(var i = 0; i < enemyUnits.length; i++) {
if (enemyUnits[i].active && Phaser.Math.Distance.Between(100, 100, enemyUnits[i].x, enemyUnits[i].y) <= distance) {
return enemyUnits[i];
}
}
}
}
};
``````

Path followers don’t have velocity.

``````function update(time, delta) {
// `delta` === `this.game.loop.delta`

// `pathDelta` is distance per 1 update.
// Convert it to a 1-second velocity
const velocity = follower.pathDelta.clone().scale(1000 / delta);
}
``````

Thank you again! You’re incredibly helpful