Jump to content

AI of enemies, do things from time to time, etc ...


dandorf
 Share

Recommended Posts

AI enemies do things from time to time, etc ... 

 

It is time in my game, I have to create enemies. I do not know how to deal with the issue, I would like you to tell me some options there. 

 

How to make the enemy walk to the left and to the right, jump from time to time, etc .... that sort of thing. 

 

Thanks!!

Link to comment
Share on other sites

I set up a state machine and use random (as alex_h says) to switch to different states.  This lets you make sure that a state has finished before it switches to doing something else.  So for walking left, you might have a timer that counts 5 full animation cycles before it stops (unless it bumps into something).

Sometimes you don't want it to do the same thing twice in a row (like jump for instance) so you can add cool-down counters.

There are a lot of ways of doing AI for your enemies, but I've always found the most interesting results come from coding up something very simple to start with and then just adding a new rule every time you notice an enemy do something dumb.  If you happen to think "wouldn't it be cool if the enemy did X?" this approach makes it pretty easy to experiment with a few rules to add a new behaviour too.

One word of warning: if you are doing very complex systems, the code can end up quite spaghetti-like and that makes it very hard to debug... I had no problem using this approach for the AI in Aztec God Game, but when I wrote the AI for Stratego it became too messy and I had to refactor the whole thing.

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...