How do I Give AI to my enemy?

Get help using Construct 2

Post » Sun Jan 04, 2015 3:44 am

So the game I'm making includes walls and the player and enemy have to be able to move around and my intention is to make it move around randomly and target the player once caught in sight. I already made player movements and stuff. PLease help me! (this isn't a platformer game and there are obstacles) :cry:

Here are some pics
Image
Image
Last edited by Thomas Harding on Sun Jan 04, 2015 8:04 pm, edited 7 times in total.
B
5
Posts: 6
Reputation: 254

Post » Sun Jan 04, 2015 3:46 am

If this is platformer/side scroller game, this might fit your preference
https://www.scirra.com/tutorials/1320/p ... enemies-ai
B
16
S
7
Posts: 301
Reputation: 2,726

Post » Sun Jan 04, 2015 2:39 pm

I forgot to mention it isn't a platformer..
@sgn15
B
5
Posts: 6
Reputation: 254

Post » Sun Jan 04, 2015 3:20 pm

Ok. I would suggest making sensors (invisible objects). Better yet, make different sensors for different movement directions.

If enemy overlaps sensor_right, move right.
If enemy overlaps sensor_left, move left.
and so on.
then you can also check line of sight or distance from player.
B
16
S
7
Posts: 301
Reputation: 2,726

Post » Sun Jan 04, 2015 5:21 pm

Ok, thanks, I never thought of that! I'll try it!
@sgn15
B
5
Posts: 6
Reputation: 254

Post » Sun Jan 04, 2015 5:30 pm

It didn't work out that well.
B
5
Posts: 6
Reputation: 254

Post » Sun Jan 04, 2015 5:56 pm

you might want to show a diagram or the screenshot of your layout because I don't know the theme/logic of your game
B
16
S
7
Posts: 301
Reputation: 2,726

Post » Sun Jan 04, 2015 6:38 pm

OK
B
5
Posts: 6
Reputation: 254

Post » Sun Jan 04, 2015 10:55 pm

Message: Thomas Harding is not yet permitted to post plain text URLS (300 rep required). 1 URLS removed. Why?
@sgn15
B
5
Posts: 6
Reputation: 254

Post » Mon Jan 05, 2015 9:28 am

@Thomas Harding
I can't make something out of those large pics. I mean just a simple diagram made from MS paint or a screenshot of your layout view in C2 would help explain what happens in your game (aside from what you have explained so far) since you said the sensors did not worked out so well. I don't know how you did it specifically.

Aside from sensors, you can also check your distance (between player and enemies) as another condition for enemy AI.

You might also want to use instance variables to store the direction an enemy is currently facing. So an enemy who is facing right that overlaps a sensor will go left, while an enemy facing right that overlaps sensor will go left. something like that.

Try to summarize the things you want to take into account with in the AI mentally or in a piece of paper before trying to code them. Good luck.
B
16
S
7
Posts: 301
Reputation: 2,726

Next

Return to How do I....?

Who is online

Users browsing this forum: Lancifer, MPPlantOfficial, Sup with that?, Yahoo [Bot] and 60 guests