A little help for making a simple AI

  • Hi .

    Fist of all , excuse me for my poor English .

    Well , I am making a game . There is a player and 10 zombies . Now I want to make simple AI . When the player gets near to the zombies , they attack him . But I don't know how to make this !

    In GM 8.0 , there was a function called : Distance-to-object()

    But I couldn't find such a thing in Construct 2.0 .

    I tried to use this code , but unfortunately , it didn't work <img src="smileys/smiley19.gif" border="0" align="middle" /> ... :

    Event 2 : System : zombie.x <= player.x + 50

              System : Zombie.y <= player.y +50

    Action : blah blah blah

    Event 1 : System : zombie.x >= player.x + 50

              System : Zombie.y >= player.y +50

    Action : blah blah blah

    Well , I think this code didn't work because there are more than 1 zombie in the game , just guessing ...

    Now , my questions :

    1 . Why didn't the code work ?

    2 . Is there any other way for doing this ?

    Thanks for reading . <img src="smileys/smiley1.gif" border="0" align="middle" />

  • hmm i think you can use distance(player.x,player.y,enemy.x,enemy.y)<...

    also there is a trick is that you put a sprite for the range if player overlap that sprite it do blablabla..

    about your code i think you should use for each ( i'm not sure )

  • Gamer, check out this thread: http://www.scirra.com/FORUM/enemy-movement-and-ai_topic49926.html?KW=

    There is a link to an example that might help you.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Thanks for the tips guides , well , I came to the conclusion that the easiest and fastest way is the hidden sprite trick ...

    And Wastrel , thanks for the link , I found some other useful information in that thread .

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)