Hi, I started making a 2D beat em up game, hoping I can create a sort of Renegade / Streets of Rage style experience where the player walks along a scrolling street and kills enemies with a few strikes, until reaching boss level enemies which require more hits. I’m wondering how do you program different Enemy AI? For example if I want one enemy to quickly walk to the player and attack with a punch, kick, punch… Another group of enemies might wait until the player is close by and then they might try to surround him… 2 on his left, 2 on his right… If possible I’d like the AI to be unpredictable and not too repetitive…
I’ve recently seen a tutorial on The Gem Dev channel about hitboxes for melee and it’s very useful. I think you can fine tune strike areas quite precisely using different hitboxes. So I think I understand a little bit, the basics, about collisions. But I’m stuck at actually programming the Enemy AI to do certain strikes and attacks on the player. By any chance does anyone have example code out which shows some Enemy AI fight code for a scrolling 2D Beat Em Up?
I am not going to give you some code to program your AI but i am going to give you the manner i used in the past for making a little AI.
I used to write on paper the different rules to drive the AI components.
By example, i wrote some things like that to force ennemy(ies) pursuing the hero :
- first, if ennemy(ies) are far away of the player (150 pixels away), ennemy(ies) must not follow nor attack the player
- second, if 2 or more ennemies are closer enough of the hero, only one can follow and attack the player
- and so on…
What is important here is to describe every rules of AI in clear language to be able after to translate them into visual scripting conditions and actions but also in a programming langage.
With this method , you are not dependant of the games engine or informatic language you’ll use to realize your game.
Thanks for the info Amigo. I’ll try writing some rules down as you suggested. I’m very new to GDevelop and game programming in general, an absolute beginner, so I don’t have a clear understanding of how to even start a single fight scene in my game. I’ve been learning some basic things by copying the examples in tutorial videos for these past 2 days but I can’t find a tutorial video or code which actually demonstrates how to get an enemy to attack me with various strikes.
Well! As you say you are a new GDevelop user, it’ll be most important to write the rules on paper. As i said before, you will so be independant of the tool(s) you’ll use to implement your AI.
When you’ll do like that, you will see all will be easier and clearer.
Good work and don’t hesitate to say us the result of your reflexion.