NikoFenix Posted May 7, 2017 Share Posted May 7, 2017 Hello how are you, I'm developing a rpg game and I'm in the development of enemies, in short my problem I have an enemy (spider) that is dedicated to securing the player, but I can only ahcer follow the mouse, some solution ? My code is PRELOAD < game.load.image('ball', 'Multimedia/Imagenes/Personajes/spider.png'); > CREATE game.physics.startSystem(Phaser.Physics.ARCADE); balls = game.add.group(); balls.enableBody = true; for (var i = 0; i < 50; i++) { var ball = balls.create(game.world.randomX, game.world.randomY, 'ball'); } ------------ HERE IS THE PROBLEM --------------- UPDATE if (w.isDown || a.isDown || s.isDown || d.isDown) { // First is the callback // Second is the context in which the callback runs, in this case game.physics.arcade // Third is the parameter the callback expects - it is always sent the Group child as the first parameter balls.forEach(game.physics.arcade.moveToPointer, game.physics.arcade, true, 200); } else { balls.setAll('body.velocity.x'); balls.setAll('body.velocity.y'); } Link to comment Share on other sites More sharing options...
samid737 Posted May 8, 2017 Share Posted May 8, 2017 Hi, here is an example of how in your case your enemies can follow your player: Link to comment Share on other sites More sharing options...
NikoFenix Posted May 9, 2017 Author Share Posted May 9, 2017 Thank you so much!! Link to comment Share on other sites More sharing options...
Recommended Posts