How do I make an AI follow a path

Discussion and feedback on Construct 2

Post » Mon Jun 18, 2012 11:54 am

Hi All,
I am very new to construct2.Hardly few weeks old.
I want to achieve the following in my game.

Make the player move in any direction - I did that using 8-direction
To make the bad-guy move only in particular direction - ??

these images might be very clearly saying what I am looking for:




and




Thanks
Karthikeyan
B
6
Posts: 30
Reputation: 585

Post » Mon Jun 18, 2012 2:45 pm

@pinastro, the easiest solution that i can think of now, is to only move certain enemies in certain bridges, i mean, if you don't make all of them walk in all of the bridges is easy to simple put an invisible sprite in each path and everytime that an enemy touch one of them, you simple change it's direction. But if you wanna move all of them in all of the bridges it would be a little more complicated but can be done, if you are not good with the first solution, let me know and i can make you something that maybe you can use as an example, ok?
See ya!
B
28
S
5
G
4
Posts: 51
Reputation: 3,857

Post » Mon Jun 18, 2012 3:23 pm

Here is how I would do it with invisible sprites for the islands and angles of the bridge paths.

Commented .capx: EnemyBridgePatrol.capx (r95)
B
27
S
8
G
8
Posts: 903
Reputation: 8,452

Post » Mon Jun 18, 2012 3:23 pm

@Behamut

I certainly do not want to move all of them in all the bridges.
Can u give me the link that explains putting an invisible sprite method.

I am not much well versed with the engine... something like this game
http://www.scirra.com/construct2/demos/moon-shield

the objects never move out of the orbit..may be i am giving a wrong example.

thanks
B
6
Posts: 30
Reputation: 585

Post » Mon Jun 18, 2012 3:24 pm

@Nimtrix let me check ..thanks :)
B
6
Posts: 30
Reputation: 585

Post » Mon Jun 18, 2012 3:55 pm

I did this with my behavior i made. Here is a demo.

Demo

Behavior
B
17
S
9
G
7
Posts: 249
Reputation: 6,922

Post » Tue Jun 19, 2012 1:27 pm

this is the tutorial for making a platform game, inside there is the explanation on how to make invisibles sprites, and maybe you can learn a few new things by reading it,
http://www.scirra.com/tutorials/253/how-to-make-a-platform-game
hope it is useful to you, anyway, sorry for the delay in the response, i believe we are in differents times zones,
anything else, just ask, see ya!
B
28
S
5
G
4
Posts: 51
Reputation: 3,857

Post » Tue Jun 19, 2012 7:53 pm

@all thanks.

I was caught up in my daily job schedule :(

I am trying to figure out how the events were written for the EnemyBridgePatrol.capx given by @Nimtrix
I guess I need a some manual sort to understand a little more complex (programming like) features in construct2.
Please give me some time to understand what you have given :)


@rFisher
rfisher's solution sounds an easier way..but i still might have to think about the AI movement in this case.This this way I stumbled upon one few questions about SOLID behaviour.

(a) Can we dynamically set the 'Solid' behaviour in-between (during)the game play ? if so how ?

(b) Can we set the 'Solid' behaviour valid only to the AI and not for the player ?

i have tried something here
http://pinastro.files.wordpress.com/2012/06/solidbehaviour.jpg

what i want is the player not stopped by the invisible solid object on both side of the bridge (I am not really sure how valid is this question?)

B
6
Posts: 30
Reputation: 585

Post » Tue Jun 19, 2012 8:19 pm

@pinastro

Here is the CAPX for the demo you saw.

Demo capx

Its really simple the way it works. I do plan on adding an Array string that will hold the way points then using a invisible sprite, but i haven't implemented it yet.

I'm not sure on your question (a), but i would have to say no.

For question (b) the answer is yes.
B
17
S
9
G
7
Posts: 249
Reputation: 6,922

Post » Tue Jun 19, 2012 9:39 pm

I added some more comments to clarify how it all works (hopefully). You should probably read up on instance variables and booleans in the manual. 'For loops' as well, if you're not familiar with how loops work.

Anyway, if there's anything specific you need explained, just ask.

More commented .capx: BridgePatrol_Comments.capx (r95)Nimtrix2012-06-19 21:39:54
B
27
S
8
G
8
Posts: 903
Reputation: 8,452

Next

Return to Construct 2 General

Who is online

Users browsing this forum: No registered users and 17 guests