Enemy AI for a 2D platformer

Get help using Construct 2

Post » Mon Jun 03, 2013 4:26 am

I have multiple slimes that crawl around and I want them to follow the player when they get in a certain range of him. I want them also to have minds of there own so they all don't do the same thing.
B
9
S
1
Posts: 42
Reputation: 622

Post » Mon Jun 03, 2013 5:39 am

Well AI is a tough thing. The follow the player, you will want to use the Distance expression to check if the player is within a certain distance of slime, if so change the slime's actions.
B
101
S
32
G
12
Posts: 1,549
Reputation: 21,993

Post » Mon Jun 03, 2013 9:17 am

Give them a variable called state

Every x seconds change the state to random (walk left/right whatever)
if enemy is in x distance set state to follow / attack and so on :)
B
33
S
6
G
7
Posts: 339
Reputation: 7,426

Post » Tue Jun 04, 2013 12:08 am

Thanks, but I still need help xD. I dont know how to do the state thing. When I name a variable it wont let me add a left and a right state.
B
9
S
1
Posts: 42
Reputation: 622

Post » Tue Jun 04, 2013 1:10 am

You might want to start out going through the platformer beginner tutorial on the tutorials page. It's basics will really help out.
B
101
S
32
G
12
Posts: 1,549
Reputation: 21,993

Post » Tue Jun 04, 2013 8:01 pm

If you're going to have delays on actions, also set it as instance variable instead of the "Wait 1 seconds" condition. Guarantees each instance has their own timing.

eg:
Every Tick
>Add 1*dt to Sprite.Time
if Sprite.Time=1
>Subtract 1 from sprite time
>>Do actions.
B
21
S
8
G
6
Posts: 346
Reputation: 4,891

Post » Sat Aug 17, 2013 5:50 pm

would be awesome if someone posted an e.g of an enemy AI for a platformer
B
37
S
6
G
2
Posts: 249
Reputation: 3,127


Return to How do I....?

Who is online

Users browsing this forum: NN81, Seruza and 10 guests