Enemy movement and AI

  • I�m working on my topdown rpg-style game and think it�s time to start tinkering with enemies, their movement and AI (somhing like: they patrol back and forth a certain path and if they "see" the player they go after him and start attacking)I haven�t done anything like this before (made some very simple stuff in GM8.1 last year, no AI or line of sight etc..)

    Was hoping someone could give me some starting tips and pointers to work from so I can learn it.

    Thanx

  • Here is a simple example of something I've used in some projects. It basically keeps a state of awareness for the enemy, and when changed to a different state, reacts appropriately.

    Use WASD to move the player. When you get within 180 pixels, the enemy goes into an alert state. When you get within 90 pixels, the enemy turns and attacks the player.

    http://dl.dropbox.com/u/38038537/examples/AI_Example.capx

  • sweet! thanx! I?ll look into it as soon as I have reinstalled windows764bit.. installed the Win 8 Preview but forgot all about dual-boot <img src="smileys/smiley17.gif" border="0" align="middle" />

  • Just how I would do it too.

    Phases/states and while loops.

  • Here is a simple example of something I've used in some projects. It basically keeps a state of awareness for the enemy, and when changed to a different state, reacts appropriately.

    Use WASD to move the player. When you get within 180 pixels, the enemy goes into an alert state. When you get within 90 pixels, the enemy turns and attacks the player.

    http://dl.dropbox.com/u/38038537/examples/AI_Example.capx

    I have another problem:

    I try duplicating your enemy, BUT the distance event stays respective to THE ORIGINAL enemy.

    As in, when I walk to the clone enemy, it won't trigger alert stage; However, when I walk to the original enemy, even the clone(Far away) come chasing.

    Please help.. your previous post helps a lot!

  • ZhaoYun, I have updated the original capx:

    http://dl.dropbox.com/u/38038537/examples/AI_Example.capx

    This version creates multiple copies of the enemy object, then uses the "pick nearest to" event to determine against which object the sub-events should be run.

    I hope this helps.

  • ZhaoYun, I have updated the original capx:

    http://dl.dropbox.com/u/38038537/examples/AI_Example.capx

    This version creates multiple copies of the enemy object, then uses the "pick nearest to" event to determine against which object the sub-events should be run.

    I hope this helps.

    Thanks for the following up!

    I try your new version, but it raise a problem, when I walk towards a group of enemy, only few come chasing.

    So, I think, and I change the "Pick Nearest to" to "System->For each" and it works!

    Wastrel Thank you so much!!! Now I further understand how those condition works!

  • Wastrel

    I know this is old. I would like to take a look at this example but am unable to download. Any chance for a new link?

    Thanks.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Yes, error 403 in Dropbox. Will be nice testing this. I will can use in other projects that don't use enemy's AI.

  • Hello!

    Is there a chance for a re - upload please?

    Thanks in advance

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