enemy AI individual

Get help using Construct 2

Post » Fri Jan 24, 2014 2:53 am

I have a two enemies with one event sheet but i cannot manage to make them behave like separated individual AI. I use 'For each' and also give the enemy instance variables but it's not working.

Any suggestions?
Posts: 80
Reputation: 687

Post » Fri Jan 24, 2014 6:08 am

AI is a complex field as you know doubt are aware by now....

Could you please clarify your question a little better..

The enemies you speak of are instanced objects of the same entity yes?

If you want complex AI behaviours you often need to create variables that control or influence the behaviour first in some way

like a cascading flow chart..

for example...having only one enemy attack if its close to the player is suitable for some games but not others or for other enemy types

like a hive mind enemy

to create specific actions you need to discuss what specific actions you wish to work on ...

AI is a vast field of interconnected functions that affect and attribute to events in real time...

its rarely as simple as adding a singular feature

its about flowchart conditions that lead up to other events

An Example AI flowchart would be

Has Enemy detected player? yes/no

if it did detect the player ..how did it detect player (method)

if enemy has detected player what should it do next
(pursue player or flee or some other action?)(Deterministic function)

once deterministic function is calculated ( which can be done on a sliding table or scale based on values affected elsewhere)

proceed with action every few seconds rather than every tick
( this allows realistic adjustment of actions that the player could respond to)

So basically its a complex series of feedback mechanisms that you create

idle default mode-> alert mode-> attack mode-> return to default mode or continue attack mode-> defeat modes must be catered for also

building ai is probably the most advanced work you will ever do for a game...but try to break it down into understandably sub routines or feedback loops to make sense of it

Using the above example

you may restrict only enemy instances that are within a certain "distance" to the player by adding a subroutine that does something like


FOR EACH (enemy)
SYSTEM--> compare two variables--> player.x, player.y, enemy.x,enemy.y is less than 100 pixels

ACTION--> Enemy(Find PATH to Player.x,player.y)
understanding the basics of flow charts and actions will help you write better AI routines...
but they are no different than any other programming when you get down to it

try to think of it like a PARTICLE system

you set the basic characteristics up but each entity has random or specific feedback affected rules that determine its behaviour

you must as a programmer allow for each possible feedback behaviour other wise your AI will get stuck in loops and be unable to change its own behaviour..

if you posted your AI routines I could go over it for you if you like..

When in doubt..or you are lost in a Zombie apocalypse or someone is giving you a hard time..Remember one thing..... Read the Construct 2 Manual..it will save your life.:)
Posts: 318
Reputation: 7,685

Return to How do I....?

Who is online

Users browsing this forum: sublimate and 2 guests