Creating Basic AI Pathfinding

Hi! I have more of a general question.
In a platformer game I want to create an enemy that aggros and follows the player jumping after him from platform to platform. Where do i start with it? Are there any good guides for GML to code simple AI logic? How do you approach such problems in general?Are there eny tips for beginners who do it in GMS or a must-read of some kind?
So in my mind, what i need is to make my enemy object analyse that it is at the end of a platform then judging by point_direction it needs to decide if it needs to jump or to drop... but how far to jump? Is it another collision detection?
It seems that the easiest way to do it is to make a net of place_meetings and if statements, but i am worried that if i do that and several objects on the screen would be constantly checking for collision it would have a huge impact on performance.
Where do i start with programming simplistic AI?
What if i am overthinking it and maybe i can just fake AI with just making objects move along platforms following player and when they are not touching a platform their sprite changes to a jumping sprite and back to running one when they "land".
I know that there is a path creation functionality that i haven't used. Is is a good way to programm such behaviour? like adding points around objects with path_add_point or something?

Sorry for a rant)
 

Nocturne

Friendly Tyrant
Forum Staff
Admin
From your post I think I can safely say you are on the right track! :)

Basically, with this kind of task, you should break it down into "bite-size" chunks then start programming them a bit a time. For example, you say "So in my mind, what i need is to make my enemy object analyse that it is at the end of a platform then judging by point_direction it needs to decide if it needs to jump or to drop", HOWEVER, before that you need to make the enemy stand on the platform, then move along the platform, then detect the edge of the platform and turn around. Those are the FIRST three steps required for the AI, so do that. Once you have that, you can then easily modify the "reach end, turn around" code to perform a different action, like jump or fall.

What if i am overthinking it and maybe i can just fake AI with just making objects move along platforms following player and when they are not touching a platform their sprite changes to a jumping sprite and back to running one when they "land".
This is not "fake" AI! This is basic AI 101 and exactly what you should be doing to start with. Like I say above, in general good AI starts with a basic foundation that you then add to. You don't just start programming a complex AI from scratch. To add to what you wrote, you could expand it to something like: " objects move along platforms following player and when they are not touching a platform, if the player is above them or beside them then they jump, and if the player is below them then they fall." This has modified the basic simple AI you mentioned to have a more complex behaviour. Once you program THAT you can then add further complex behaviours like "if the player is beside the enemy shoot, otherwise jump or fall".

I know that there is a path creation functionality that i haven't used. Is is a good way to programm such behaviour? like adding points around objects with path_add_point or something?
Nope, I'm afraid that the built-in pathfinding is really only good for top down...
 
Thank you! Actually the thing that i can't get my had around is the enemy behaviour when the enemy is on a platform and the player is on a platform straight below. So AI needs to find its way to the edge of its platform, then fall to a platform below then follow player.. when i am thinking about it probably i can set a place_meeting check and if it is true set enemy speed to +x or -x so it can go to the end of its platform.
I probably need to write it down on paper step by step)
 

Nocturne

Friendly Tyrant
Forum Staff
Admin
I would suggest that, while writing stuff down is useful, there's nothing quite like DOING it, so make a start! Get your enemy moving on the platform first, then you can start to experiment and see how you can achieve further goals. :)

Oh, and also, have a look and see how other games similar to the one you are making deal with these things. Watching gameplay videos of those games can often give you clues as to how things are done, or not done.
 
Top