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

Get help using Construct 2

Post » Fri Oct 09, 2015 10:30 am

Message: punner is not yet permitted to post plain text URLS (300 rep required). 1 URLS removed. Why?
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.)
B
3
Posts: 7
Reputation: 189

Post » Fri Oct 09, 2015 10:37 am

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

Snake
If your vision so exceeds your ability, then look to something closer.
Moderator
B
134
S
30
G
86
Posts: 5,420
Reputation: 59,526

Post » Fri Oct 09, 2015 10:43 am

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.
B
3
Posts: 7
Reputation: 189

Post » Fri Oct 09, 2015 1:44 pm

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?
B
3
Posts: 7
Reputation: 189

Post » Fri Oct 09, 2015 1:53 pm

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?
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Fri Oct 09, 2015 2:02 pm

Right now, the head is moving automatically and I'm just updating it's X and Y co-ordinates every tick.
B
3
Posts: 7
Reputation: 189

Post » Fri Oct 09, 2015 2:15 pm

follow same pattern for other object
B
252
S
39
G
15
Posts: 1,964
Reputation: 40,753

Post » Fri Oct 09, 2015 4:31 pm

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) .
B
29
S
8
G
4
Posts: 767
Reputation: 5,985

Post » Fri Oct 09, 2015 10:30 pm

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
Bushy Ball\Boatman Bill\Sticky Web\Snake

Image ImageImageImage

During the gold rush it was a good time to be in the pick and shovel business
B
46
S
14
Posts: 252
Reputation: 5,352


Return to How do I....?

Who is online

Users browsing this forum: diamantico21, ratboy3 and 41 guests