How do I program simple AI?

Get help using Construct 2

Post » Thu Sep 24, 2015 12:36 am

vegapomme27 wrote:Hi mestrejedi3221.

First I would include the platform behavior to enemies (or 8 directions if it is no platformer), it will be much easier to control their movements this way (don't forget to put "Default controls" off).
Also use an instance variable in enemies to memorize the player even if he left the LOS, being able to run after him then. Let's call it "Memory" (initial value = 0)

About shooting I would do something like :
("-" represents sub event)

if Enemy has LOS to player : Set memory = 1
-Enemy compare X : if greater than Player. X : Set mirrored
-Enemy compare X : if lessthan Player. X : Set not mirrored
-Every 3 seconds : Spawn bullet

About moving to the hero :

if Enemy has NOT LOS to player :
and Enemy memory = 1
-Enemy compare X : if greater than Player. X : Simulate control Left
-Enemy compare X : if less than Player. X : Simulate control Right

Does it help ?

Vega


Thanks man this work
B
9
S
1
Posts: 7
Reputation: 429

Post » Thu Sep 24, 2015 12:39 am

Message: mestrejedi3221 is not yet permitted to post plain text URLS (300 rep required). 1 URLS removed. Why?
Lordshiva1948 wrote:mestrejedi3221 sorry here is AI.capx


Thanks for the system.
With small changes, this is perfect to my game.
B
9
S
1
Posts: 7
Reputation: 429

Post » Sat Sep 26, 2015 6:27 am

You're welcome, nice to help :D
B
23
S
5
Posts: 42
Reputation: 1,261

Previous

Return to How do I....?

Who is online

Users browsing this forum: dop2000, namaewayukidesu and 9 guests