GDevelop 5 Example - Simple Platformer Enemy AI (2025)

This is a very simple AI for enemies that run left and right and jump over obstacles of different heights.

First, add your left-right running enemies to the 'Enemies' group and all the obstacles to the 'Obstacles' group.


Add a boolean variable called 'isHigh' to the obstacle objects. True = 2 blocks high, False = 1 block high.


Add a "JumpRay" point to the enemy objects.


Next, create a new extension and give it a name. In this case, I’ve called it 'Enemy_AI'.


Next, add a new behavior and give it a name. I named it 'Simple_Enemy_AI'. Then, fill in the fields.


Next, add any additional behaviors that this behavior requires. In this case, I’m using the platformer behavior for enemy movement.


Next, add a function to the behavior and use doStepPreEvents.


Next, add an Action function and name it 'JumpOverObstacle' or choose a name that fits your needs.


Now, find and add the created behavior to the enemy objects. In this case, add it to the GreenEnemy and RedEnemy.


Next, call the function in the event editor.



And there you have it! Now you have a very simple enemy AI!

Comments