How do I make an AI that follows the player around?

0 favourites
  • 9 posts
From the Asset Store
Player's Follower
$7 USD
30% off
Players follower. use it for anything which follows the player
  • Hi guys,

    So I'm basically making a twist on the classic Snake game for a jam.

    The view is isometric.

    I have 3 active game objects - Head, Food, and Follower.

    When Head hits Food, I've managed to use the collision events to destroy Food.

    Now I want to create a Follower object where the Food was destroyed and start following the path that Head was going on. I tried using the Pin behavior but that simply keeps the position of Follower relative to Head and doesn't actually move along the same path that Head traveled on.

    Here's a link to the quick test project I made - Thanks! (Sorry if it's a noob question. Haven't used Construct for a year.)

  • This is a .capx I did a long time ago, but may be of some use to you.

    Snake

  • Hey zenox,

    I actually referred that when I started my project.

    The thing is that for my project, each individual Follower has special properties and abilities. Each follower can also be destroyed by enemy bullets and that will simply shorten the snake.

    Also, the Snake.capx project basically destroys the snake with every step and creates it again on the next tile, but since my project has smooth sprite based movement with walking animations, it won't be that practical.

    Thanks for the quick reply though.

  • Okay, so I thought of something that might work but need someone with a bit more experience to actually figure it out.

    To make the Follower follow the exact route as the Head, how about I spawn invisible "Waypoints" every second at the X and Y co-ordinates of the Head. Then, once the Follower is spawned, I use the Path-Finding behavior to go to the nearest Waypoint and follow all subsequent Waypoints?

    The problem is that I have no idea how to do this in the event-based structure.

    Can anyone help?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I could think of numerous ways to do this, depending on how you have your events/movement set up right now..

    What movement behaviour are you using?

  • Right now, the head is moving automatically and I'm just updating it's X and Y co-ordinates every tick.

  • follow same pattern for other object

  • every tick ----- Set angle tward position head.X,Head.Y

    --------------------Move 1 px forward.

    add a random number to the Head.X and Y and the follower wont always try to be on top of you player.

    You can use the same trick with pathfinding, just find a path to head.X and Head.Y then add a random (-10,10) .

  • Have a look at a capx I wrote a while ago https://www.scirra.com/tutorials/4804/s ... -16-events

    You could add your special items to the tail, by adding

    Every tick > (your sprite) set position to (snake_body.x,snake_body.y)

    To reduce the snake if its hit by something , just subtract some amount from the growth variable

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