#Enemy AI Pathfinding toward players in a Sidescroller

6 messages · Page 1 of 1 (latest)

iron plover
#

Hi all, new to Godot, and game programming.

Currently creating a 2D sidescroller with some friends, and I am working on enemy pathfinding.

I was wonder, what is an ideal way to go about implementing pathfinding in a side scroller for ground units? I've done reasearch and found 2 options I am thinking about using:

RayCast will be used for both

  • Bread-crumb approach
  • Navigation mesh with agent

What I like about the bread-crumb approach is I don't need to create navigation mesh's everywhere.

Since enemies don't need to move around obstacles, but up and down, I found the idea of a navigation mesh to be overkill, however, perhaps I don't understand the full extent and capabilities of it.

I also need to get the enemy to attempt jumping when it encounters an obstacle. This can be done with both approaches I am assuming.

But I wanted to see what others have come up with with creating enemy pathfinding in a 2D side scroller where height needs to be considered vs a top-down, as I am new to game development in its entirely, and would love to see other solutions, and ideas

If you have any resources, I would be grateful if you sent them my way!

ivory ice
#

I think you have 3 common options for this.

#

the "All raycast" option that you can do when it is a small project with very few actors. it does scale the worst if you have a large world with many actors at the same time

#

the "AStar2D" where you manually add points in script on the key positions and then make your actor script move the loosely from point to point or figure out when to jump up.

#

the "NavigationMesh", where you add thin lines of navigation mesh polygon on all your walkable surfaces and connect the platform corners and positions below with NavigationLink2D. this way you can use the NavigationAgent2D and everytime this agent reaches such a link in the pathfinding it will give a signal that you can use to figure out the "jump" up and down between the two link positions before you continue along the normal path again.

iron plover
#

I didn't see AStar2D in the list of nodes. Do I need to add it manually or something?

Also - I'm not sure what you mean by using a link for jump? Wouldn't you just bake out obstacles, so the path created goes around it? Or are you referring to when you have a two platforms separated by a gap/chasm, and you link the two platform meshes?