Path follower position update

The x and y coordinate of my path follower stays static throughout the path, I was wondering if there’s a way to update that continuously so I could check the range between it and other sprites etc? Thanks in advance!

Do you mean the path follower x and y values don’t change while it appears to be moving on the path?

Yes, exactly

And how can you tell?

I’m logging the enemies at half second intervals and the x and y is static

Can you show the scene code?

Sure thing

class Game {
  preload() {
    this.load.image('base_tiles', './assets/16x16_Jerom_CC-BY-SA-3.0.png')
    this.load.tilemapTiledJSON('tilemap', './assets/practiceMap.tmj')
    this.load.image('littleFella', 'assets/littleFella.png')
    this.load.image('tower', 'assets/tower.png')
    this.load.image('cannonBall', 'assets/cannonball.png')
  }

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

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

    //fire the canon from the tower
    this.cannonBall = this.physics.add.group()

    //iterate up to total number in enemies group
    this.count = 0

    //shoot count
    this.nextTic = 0

    //creates the path followers
    this.time.addEvent({
      delay: 500,
      callback: () => {
        if (this.count < this.enemies.children.entries.length) {
          this.createLittleFella(this.count)
          this.count++
        }
      },
      loop: 20,
    })

    this.gfx = this.add.graphics();

    this.enemies = this.add.group({runChildUpdate: true });
    this.enemies.create(-40, 32, 'littleFella')
    this.enemies.create(-40, 32, 'littleFella')
    this.enemies.create(-40, 32, 'littleFella')
    this.enemies.create(-40, 32, 'littleFella')
    this.enemies.create(-40, 32, 'littleFella')
    this.enemies.create(-40, 32, 'littleFella')

  }

  update() {
    if(this.time.now > this.nextTic) {
      this.updatePosition()
      this.nextTic = this.time.now + 3000;
    }
  }


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

    path.lineTo(-40, 32)
    path.lineTo(45, 32)
    path.lineTo(45, 465)
    path.lineTo(160, 465)
    path.lineTo(160, 385)
    path.lineTo(110, 385)
    path.lineTo(110, 270)
    path.lineTo(240, 270)
    path.lineTo(240, 370)
    path.lineTo(305, 370)
    path.lineTo(305, 45)
    path.lineTo(450, 45)
    path.lineTo(450, 465)
    path.lineTo(530, 465)

    let mover = this.add.follower(path, -40, 32, this.enemies.children.entries[count].texture.key);
    this.physics.add.existing(mover)

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

  
    this.time.addEvent({
      delay: 10500,
      callback: () => {
        mover.destroy()
      },
      loop: 20,
    })

    return mover
  }

  updatePosition = function() {
    var enemyUnits = this.enemies.getChildren();
    if (enemyUnits) {
      for(var i = 0; i < enemyUnits.length; i++) {
          console.log(enemyUnits[i])
      }
    }
  }
  

};

The first 6 enemies aren’t followers and won’t be moving, it looks like.

They’re moving when I load it? Like I see them move on the path?

The “enemies” group has 6 sprites that aren’t followers and don’t move. You’re logging these sprites.

There are also 6 “movers” who are followers but they aren’t in the enemies group.

I see. Thank you. Can you help me understand how to make group members follow a path?

Instead of enemies.create() you use

this.enemies.add(mover);

Thank you for your time! I feel foolish, that solved my issues. Now I just need to figure out how to actually aim.