Enemy movement and AI

Get help using Construct 2

Post » Fri Mar 09, 2012 2:33 pm

Im working on my topdown rpg-style game and think its 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 havent 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
B
21
S
7
G
4
Posts: 221
Reputation: 5,070

Post » Fri Mar 09, 2012 4:55 pm

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.capxWastrel2012-03-09 16:56:04
Don't see the fnords and they won't eat you!
B
75
S
16
G
12
Posts: 322
Reputation: 11,608

Post » Fri Mar 09, 2012 5:18 pm

sweet! thanx! Ill look into it as soon as I have reinstalled windows764bit.. installed the Win 8 Preview but forgot all about dual-boot
B
21
S
7
G
4
Posts: 221
Reputation: 5,070

Post » Sat Mar 10, 2012 12:52 am

Just how I would do it too.

Phases/states and while loops.
B
11
S
3
G
2
Posts: 110
Reputation: 2,410

Post » Mon May 14, 2012 9:58 am

[QUOTE=Wastrel] 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[/QUOTE]

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!
B
12
S
4
G
4
Posts: 64
Reputation: 4,014

Post » Tue May 15, 2012 5:15 pm

@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.
Wastrel2012-05-15 17:16:13
Don't see the fnords and they won't eat you!
B
75
S
16
G
12
Posts: 322
Reputation: 11,608

Post » Thu May 17, 2012 6:19 pm

[QUOTE=Wastrel] @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.
[/QUOTE]

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!ZhaoYun2012-05-17 18:20:04
B
12
S
4
G
4
Posts: 64
Reputation: 4,014

Post » Wed Jun 17, 2015 2:58 pm

@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.
B
4
Posts: 12
Reputation: 226

Post » Thu Jun 18, 2015 1:54 am

Yes, error 403 in Dropbox. Will be nice testing this. I will can use in other projects that don't use enemy's AI.
Bitcoin address: 12DbVQJxCUqFEWWaYdih7RLRcVWUw6PKFi
B
19
S
5
G
3
Posts: 240
Reputation: 2,839


Return to How do I....?

Who is online

Users browsing this forum: Baidu [Spider] and 1 guest