How do I create turn based AI that follows the player?

0 favourites
  • 5 posts
From the Asset Store
Fully commented source code/event sheet & sprites to create a space shooter game
  • I am trying to make a rouge-like game where the enemies follow the player 1 space at a time. I am using the moveto plugin to move the sprites. The best example I have found of this is a rouge-like called Cardinal quest (http://www.kongregate.com/games/randomn ... al-quest-2). I have tried many methods of re-creating this with no luck. Could anyone give me some pointers on how to re-create the Cardinal Quest enemy AI?

  • Probably use line of sight to detect if player is in range of enemy. Then they seem to move when you move so have so have them move towards the player by a certain number of pixels on player movement. You'll need loads of detection though for what spaces are free on the level to move to, you could have a detection sprite around each charac to check for overlaps with walls and then pick a free square to move to each time. The enemies move in exactly the same way as the player right? So once you have the player moving as you want, it would just be the same movement. Also check for if player is colliding with enemy then once this happens you can enable the sub-battle system.

  • I developed an AI that works really well (except I haven't added in collisions yet). However, I have run into a roadblock that I can't get past. (Download the capx so the explanation below will make sense. https://drive.google.com/file/d/0B0u-LjouEgnXVWI5ODl6NXVrWkE/view?usp=sharing) In my AI I used 4 squares that surround each enemy (the enemy and 4 squares are a container). These are named after their orientation around the enemy and always remain in the same spot with an every tick event. When there is one enemy on the layout the player moves, then the enemy finds which of the 4 squares is closest to the player. The enemy then moves to the square that is closest. However with 2 enemies on the screen it doesn't work. The enemy furthest away travels towards the closest enemy. What I Want: I want the 2 enemies to act independently of each other. The 1st enemy will find which of its 4 squares is closest to the player and move to it. The 2nd enemy will find which of its 4 squares is and move to it. Sorry for the long explanation, but I would greatly appreciate the help.

  • Because of the way you've set this up it's always picking the closest movement square on screen to the player regardless of which enemy it's next to. You'll have to do some checks for each enemy pick the closest movement square to the enemy that is also the closest to the player.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • How would I go about doing that exactly? I have tried using UIDs and grouping objects together by distance but I just can't seem to get it to work.

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