rhennig Posted January 4, 2016 Share Posted January 4, 2016 Hello guys, im still learning Phaser and i'm stucked now with this... how can i make a group of enemys follow my player? I've tryied with one enemy and this works perfectly:this.physics.arcade.moveToObject(this.enemy,this.player);but when i try with a group with:this.enemies.forEach(this.physics.arcade.moveToObject(this.enemy,this.player));It doesn't works... Any tip? Thanks! Link to comment Share on other sites More sharing options...
chg Posted January 4, 2016 Share Posted January 4, 2016 That's not how forEach() works, it doesn't know that you intend the this.enemy to be the objects the forEach method it is iterating over. See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/forEach or https://gist.github.com/pctroll/807fc644b3e4f05e2244 for how to use forEach() Link to comment Share on other sites More sharing options...
Cirno Posted January 4, 2016 Share Posted January 4, 2016 Maybe use update for each enemy Link to comment Share on other sites More sharing options...
Recommended Posts