Jump to content

How to make enemies pursue the player ?


donpink
 Share

Recommended Posts

I tried

 

if(Enemy.epx > this.player.x +30){
   console.log("vueeee");
   Enemy.evx = 300;
   }
 
 
-----------------
epx = ennemie position x
evx = enemy velocity x
 
But the console log work even when i am in the sky and the velocity don't grow.
Link to comment
Share on other sites

I made a function

 

 sees2:function(player, enemy)
    {
                this.physics.arcade.moveToObject(this.enemyGroup, this.player, 300, 4);     
    },
 
And call it in the update
 
 if(Enemy.epx > this.player.x +30)
 {
                  this.sees2();
}

 

It keep telling me something is wrong with this line: this.physics.arcade.moveToObject(this.enemyGroup, this.player, 300, 4);  

 

To see the game:

 

http://alekostolle.com/www/game.html

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...